home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Delphi / Video for Windows Delphi Unit / VFW.PAS
Encoding:
Pascal/Delphi Source File  |  1998-01-19  |  179.8 KB  |  4,409 lines

  1. unit VFW;
  2.  
  3. interface
  4.  
  5. uses
  6.     Windows,
  7.     MMSystem,
  8.     Messages,
  9.     CommDlg,
  10.     Ole2;
  11.  
  12. {== General ==================================================================}
  13.  
  14. type
  15.     PDWORD  = ^DWORD;
  16.     PLONG   = PDWORD;
  17.     UDWORD  = DWORD;
  18.     PVOID   = Pointer;
  19.     int     = Integer;
  20.  
  21. {-- Returns version of VFW ---------------------------------------------------}
  22.  
  23. function    VideoForWindowsVersion: DWord; pascal; 
  24.  
  25. {-- Call these to start stop using VfW from your app -------------------------}
  26.  
  27. { TODO: Where are these functions? }
  28.  
  29. // function    InitVFW: DWORD; stdcall;
  30. // function    TermVFW: DWORD; stdcall;
  31.  
  32. {-- Macros -------------------------------------------------------------------}
  33.  
  34. function MKFOURCC(ch0, ch1, ch2, ch3: Char): FOURCC;
  35.  
  36. {== COMPMAN - Installable Compression Manager ================================}
  37.  
  38. const
  39.     ICVERSION                   = $0104 ;
  40.  
  41. type
  42.     HIC                         = THandle;  // Handle to an Installable Compressor
  43.  
  44. //
  45. // this code in biCompression means the DIB must be accesed via
  46. // 48 bit pointers! using *ONLY* the selector given.
  47. //
  48. const
  49.     BI_1632                     = $32333631;    // '1632'
  50.  
  51. function    mmioFOURCC(ch0, ch1, ch2, ch3: Char): FOURCC;
  52.  
  53. type
  54.     TWOCC                       = Word;
  55.  
  56. function    aviTWOCC(ch0, ch1: Char): TWOCC;
  57.  
  58. const
  59.     ICTYPE_VIDEO                = $63646976; // mmioFOURCC('v', 'i', 'd', 'c')
  60.     ICTYPE_AUDIO                = $63647561; // mmioFOURCC('a', 'u', 'd', 'c')
  61.  
  62. const
  63.     ICERR_OK                    = 0 ;
  64.     ICERR_DONTDRAW              = 1 ;
  65.     ICERR_NEWPALETTE            = 2 ;
  66.     ICERR_GOTOKEYFRAME          = 3 ;
  67.     ICERR_STOPDRAWING           = 4 ;
  68.  
  69.     ICERR_UNSUPPORTED           = -1 ;
  70.     ICERR_BADFORMAT             = -2 ;
  71.     ICERR_MEMORY                = -3 ;
  72.     ICERR_INTERNAL              = -4 ;
  73.     ICERR_BADFLAGS              = -5 ;
  74.     ICERR_BADPARAM              = -6 ;
  75.     ICERR_BADSIZE               = -7 ;
  76.     ICERR_BADHANDLE             = -8 ;
  77.     ICERR_CANTUPDATE            = -9 ;
  78.     ICERR_ABORT                 = -10 ;
  79.     ICERR_ERROR                 = -100 ;
  80.     ICERR_BADBITDEPTH           = -200 ;
  81.     ICERR_BADIMAGESIZE          = -201 ;
  82.  
  83.     ICERR_CUSTOM                = -400 ;    // errors less than ICERR_CUSTOM...
  84.  
  85. {-- Values for dwFlags of ICOpen() -------------------------------------------}
  86.  
  87.     ICMODE_COMPRESS             = 1 ;
  88.     ICMODE_DECOMPRESS           = 2 ;
  89.     ICMODE_FASTDECOMPRESS       = 3 ;
  90.     ICMODE_QUERY                = 4 ;
  91.     ICMODE_FASTCOMPRESS         = 5 ;
  92.     ICMODE_DRAW                 = 8 ;
  93.  
  94. {-- Flags for AVI file index -------------------------------------------------}
  95.  
  96.     AVIIF_LIST                  = $00000001 ;
  97.     AVIIF_TWOCC                 = $00000002 ;
  98.     AVIIF_KEYFRAME              = $00000010 ;
  99.  
  100. {-- quality flags ------------------------------------------------------------}
  101.  
  102.     ICQUALITY_LOW               = 0 ;
  103.     ICQUALITY_HIGH              = 10000 ;
  104.     ICQUALITY_DEFAULT           = -1 ;
  105.  
  106. {-----------------------------------------------------------------------------}
  107.  
  108.     ICM_USER                    = (DRV_USER+$0000) ;
  109.  
  110.     ICM_RESERVED_LOW            = (DRV_USER+$1000) ;
  111.     ICM_RESERVED_HIGH           = (DRV_USER+$2000) ;
  112.     ICM_RESERVED                = ICM_RESERVED_LOW ;
  113.  
  114. {-- Messages -----------------------------------------------------------------}
  115.  
  116.     ICM_GETSTATE                = (ICM_RESERVED+0) ;    // Get compressor state
  117.     ICM_SETSTATE                = (ICM_RESERVED+1) ;    // Set compressor state
  118.     ICM_GETINFO                 = (ICM_RESERVED+2) ;    // Query info about the compressor
  119.                                                    
  120.     ICM_CONFIGURE               = (ICM_RESERVED+10);    // show the configure dialog
  121.     ICM_ABOUT                   = (ICM_RESERVED+11);    // show the about box
  122.  
  123.     ICM_GETDEFAULTQUALITY       = (ICM_RESERVED+30);    // get the default value for quality
  124.     ICM_GETQUALITY              = (ICM_RESERVED+31);    // get the current value for quality
  125.     ICM_SETQUALITY              = (ICM_RESERVED+32);    // set the default value for quality
  126.  
  127.     ICM_SET                     = (ICM_RESERVED+40);    // Tell the driver something
  128.     ICM_GET                     = (ICM_RESERVED+41);    // Ask the driver something
  129.  
  130. {-- Constants for ICM_SET: ---------------------------------------------------}
  131.  
  132.     ICM_FRAMERATE               = $526D7246; // mmioFOURCC('F','r','m','R')
  133.     ICM_KEYFRAMERATE            = $5279654B; // mmioFOURCC('K','e','y','R')
  134.  
  135. {-- ICM specific messages ----------------------------------------------------}
  136.  
  137.     ICM_COMPRESS_GET_FORMAT     = (ICM_USER+4)  ;   // get compress format or size
  138.     ICM_COMPRESS_GET_SIZE       = (ICM_USER+5)  ;   // get output size
  139.     ICM_COMPRESS_QUERY          = (ICM_USER+6)  ;   // query support for compress
  140.     ICM_COMPRESS_BEGIN          = (ICM_USER+7)  ;   // begin a series of compress calls.
  141.     ICM_COMPRESS                = (ICM_USER+8)  ;   // compress a frame
  142.     ICM_COMPRESS_END            = (ICM_USER+9)  ;   // end of a series of compress calls.
  143.  
  144.     ICM_DECOMPRESS_GET_FORMAT   = (ICM_USER+10) ;   // get decompress format or size
  145.     ICM_DECOMPRESS_QUERY        = (ICM_USER+11) ;   // query support for dempress
  146.     ICM_DECOMPRESS_BEGIN        = (ICM_USER+12) ;   // start a series of decompress calls
  147.     ICM_DECOMPRESS              = (ICM_USER+13) ;   // decompress a frame
  148.     ICM_DECOMPRESS_END          = (ICM_USER+14) ;   // end a series of decompress calls
  149.     ICM_DECOMPRESS_SET_PALETTE  = (ICM_USER+29) ;   // fill in the DIB color table
  150.     ICM_DECOMPRESS_GET_PALETTE  = (ICM_USER+30) ;   // fill in the DIB color table
  151.  
  152.     ICM_DRAW_QUERY              = (ICM_USER+31) ;   // query support for dempress
  153.     ICM_DRAW_BEGIN              = (ICM_USER+15) ;   // start a series of draw calls
  154.     ICM_DRAW_GET_PALETTE        = (ICM_USER+16) ;   // get the palette needed for drawing
  155.     ICM_DRAW_START              = (ICM_USER+18) ;   // start decompress clock
  156.     ICM_DRAW_STOP               = (ICM_USER+19) ;   // stop decompress clock
  157.     ICM_DRAW_END                = (ICM_USER+21) ;   // end a series of draw calls
  158.     ICM_DRAW_GETTIME            = (ICM_USER+32) ;   // get value of decompress clock
  159.     ICM_DRAW                    = (ICM_USER+33) ;   // generalized "render" message
  160.     ICM_DRAW_WINDOW             = (ICM_USER+34) ;   // drawing window has moved or hidden
  161.     ICM_DRAW_SETTIME            = (ICM_USER+35) ;   // set correct value for decompress clock
  162.     ICM_DRAW_REALIZE            = (ICM_USER+36) ;   // realize palette for drawing
  163.     ICM_DRAW_FLUSH              = (ICM_USER+37) ;   // clear out buffered frames
  164.     ICM_DRAW_RENDERBUFFER       = (ICM_USER+38) ;   // draw undrawn things in queue
  165.  
  166.     ICM_DRAW_START_PLAY         = (ICM_USER+39) ;   // start of a play
  167.     ICM_DRAW_STOP_PLAY          = (ICM_USER+40) ;   // end of a play
  168.  
  169.     ICM_DRAW_SUGGESTFORMAT      = (ICM_USER+50) ;   // Like ICGetDisplayFormat
  170.     ICM_DRAW_CHANGEPALETTE      = (ICM_USER+51) ;   // for animating palette
  171.  
  172.     ICM_GETBUFFERSWANTED        = (ICM_USER+41) ;   // ask about prebuffering
  173.  
  174.     ICM_GETDEFAULTKEYFRAMERATE  = (ICM_USER+42) ;   // get the default value for key frames
  175.  
  176.     ICM_DECOMPRESSEX_BEGIN      = (ICM_USER+60) ;   // start a series of decompress calls
  177.     ICM_DECOMPRESSEX_QUERY      = (ICM_USER+61) ;   // start a series of decompress calls
  178.     ICM_DECOMPRESSEX            = (ICM_USER+62) ;   // decompress a frame
  179.     ICM_DECOMPRESSEX_END        = (ICM_USER+63) ;   // end a series of decompress calls
  180.  
  181.     ICM_COMPRESS_FRAMES_INFO    = (ICM_USER+70) ;   // tell about compress to come
  182.     ICM_SET_STATUS_PROC         = (ICM_USER+72) ;   // set status callback
  183.  
  184. {-----------------------------------------------------------------------------}
  185.  
  186. type
  187.     PICOPEN                     = ^TICOPEN;
  188.     TICOPEN                     = record
  189.         dwSize                  : DWORD   ; // sizeof(ICOPEN)
  190.         fccType                 : DWORD   ; // 'vidc'
  191.         fccHandler              : DWORD   ; //
  192.         dwVersion               : DWORD   ; // version of compman opening you
  193.         dwFlags                 : DWORD   ; // LOWORD is type specific
  194.         dwError                 : DWORD   ; // error return.
  195.         pV1Reserved             : PVOID   ; // Reserved
  196.         pV2Reserved             : PVOID   ; // Reserved
  197.         dnDevNode               : DWORD   ; // Devnode for PnP devices
  198.     end;
  199.  
  200. {-----------------------------------------------------------------------------}
  201.  
  202.     PICINFO                     = ^TICINFO ;
  203.     TICINFO                     = record
  204.         dwSize                  : DWORD;    // sizeof(ICINFO)
  205.         fccType                 : DWORD;    // compressor type     'vidc' 'audc'
  206.         fccHandler              : DWORD;    // compressor sub-type 'rle ' 'jpeg' 'pcm '
  207.         dwFlags                 : DWORD;    // flags LOWORD is type specific
  208.         dwVersion               : DWORD;    // version of the driver
  209.         dwVersionICM            : DWORD;    // version of the ICM used
  210.         //
  211.         // under Win32, the driver always returns UNICODE strings.
  212.         //
  213.         szName                  : array[0..15] of WideChar  ; // short name
  214.         szDescription           : array[0..127] of WideChar ; // DWORD name
  215.         szDriver                : array[0..127] of WideChar ; // driver that contains compressor
  216.     end;
  217.  
  218. {-- Flags for the <dwFlags> field of the <ICINFO> structure. -----------------}
  219.  
  220. const
  221.     VIDCF_QUALITY               = $0001 ;  // supports quality
  222.     VIDCF_CRUNCH                = $0002 ;  // supports crunching to a frame size
  223.     VIDCF_TEMPORAL              = $0004 ;  // supports inter-frame compress
  224.     VIDCF_COMPRESSFRAMES        = $0008 ;  // wants the compress all frames message
  225.     VIDCF_DRAW                  = $0010 ;  // supports drawing
  226.     VIDCF_FASTTEMPORALC         = $0020 ;  // does not need prev frame on compress
  227.     VIDCF_FASTTEMPORALD         = $0080 ;  // does not need prev frame on decompress
  228.     //VIDCF_QUALITYTIME         = $0040 ;  // supports temporal quality
  229.  
  230.     //VIDCF_FASTTEMPORAL        = (VIDCF_FASTTEMPORALC or VIDCF_FASTTEMPORALD)
  231.  
  232. {-----------------------------------------------------------------------------}
  233.  
  234.     ICCOMPRESS_KEYFRAME         = $00000001;
  235.  
  236. type
  237.     PICCOMPRESS                 = ^TICCOMPRESS;
  238.     TICCOMPRESS                 = record
  239.         dwFlags                 : DWORD;                // flags
  240.  
  241.         lpbiOutput              : PBITMAPINFOHEADER ;   // output format
  242.         lpOutput                : PVOID ;               // output data
  243.  
  244.         lpbiInput               : PBITMAPINFOHEADER ;   // format of frame to compress
  245.         lpInput                 : PVOID ;               // frame data to compress
  246.  
  247.         lpckid                  : PDWORD ;              // ckid for data in AVI file
  248.         lpdwFlags               : PDWORD;               // flags in the AVI index.
  249.         lFrameNum               : DWORD ;                // frame number of seq.
  250.         dwFrameSize             : DWORD ;               // reqested size in bytes. (if non zero)
  251.  
  252.         dwQuality               : DWORD ;               // quality
  253.  
  254.         // these are new fields
  255.  
  256.         lpbiPrev                : PBITMAPINFOHEADER ;   // format of previous frame
  257.         lpPrev                  : PVOID ;              // previous frame
  258.     end;
  259.  
  260. {-----------------------------------------------------------------------------}
  261.  
  262. const
  263.     ICCOMPRESSFRAMES_PADDING    = $00000001 ;
  264.  
  265. type
  266.     TICCompressProc             = function(lInput: LPARAM; lFrame: DWORD; lpBits: PVOID; len: DWORD): DWORD; stdcall;
  267.  
  268.     PICCOMPRESSFRAMES           = ^TICCOMPRESSFRAMES;
  269.     TICCOMPRESSFRAMES           = record
  270.         dwFlags                 : DWORD ;               // flags
  271.  
  272.         lpbiOutput              : PBITMAPINFOHEADER ;   // output format
  273.         lOutput                 : LPARAM ;              // output identifier
  274.  
  275.         lpbiInput               : PBITMAPINFOHEADER ;   // format of frame to compress
  276.         lInput                  : LPARAM ;              // input identifier
  277.  
  278.         lStartFrame             : DWORD ;                // start frame
  279.         lFrameCount             : DWORD ;                // # of frames
  280.  
  281.         lQuality                : DWORD ;                // quality
  282.         lDataRate               : DWORD ;                // data rate
  283.         lKeyRate                : DWORD ;                // key frame rate
  284.  
  285.         dwRate                  : DWORD ;               // frame rate, as always
  286.         dwScale                 : DWORD ;
  287.  
  288.         dwOverheadPerFrame      : DWORD ;
  289.         dwReserved2             : DWORD ;
  290.  
  291.         GetData                 : TICCompressProc;
  292.         PutData                 : TICCompressProc;
  293.     end;
  294.  
  295. {-- Messages for Status callback ---------------------------------------------}
  296.  
  297. const
  298.     ICSTATUS_START              = 0 ;
  299.     ICSTATUS_STATUS             = 1 ;   // l = % done
  300.     ICSTATUS_END                = 2 ;
  301.     ICSTATUS_ERROR              = 3 ;   // l = error string (LPSTR)
  302.     ICSTATUS_YIELD              = 4 ;
  303.  
  304. type    
  305.     // return nonzero means abort operation in progress
  306.     TICStatusProc               = function(lParam: LPARAM; message: UINT; l: DWORD): DWORD; stdcall;
  307.  
  308.     PICSETSTATUSPROC            = ^TICSETSTATUSPROC;
  309.     TICSETSTATUSPROC            = record
  310.         dwFlags                 : DWORD ;
  311.         lParam                  : LPARAM ;
  312.         Status                  : TICStatusProc;
  313.     end;
  314.  
  315. {-----------------------------------------------------------------------------}
  316.  
  317. const
  318.     ICDECOMPRESS_HURRYUP        = $80000000 ;   // don't draw just buffer (hurry up!)
  319.     ICDECOMPRESS_UPDATE         = $40000000 ;   // don't draw just update screen
  320.     ICDECOMPRESS_PREROLL        = $20000000 ;   // this frame is before real start
  321.     ICDECOMPRESS_NULLFRAME      = $10000000 ;   // repeat last frame
  322.     ICDECOMPRESS_NOTKEYFRAME    = $08000000 ;   // this frame is not a key frame
  323.  
  324. type
  325.     PICDECOMPRESS               = ^TICDECOMPRESS;
  326.     TICDECOMPRESS               = record
  327.         dwFlags                 : DWORD ;               // flags (from AVI index...)
  328.         lpbiInput               : PBITMAPINFOHEADER ;   // BITMAPINFO of compressed data
  329.                                                         // biSizeImage has the chunk size
  330.         lpInput                 : PVOID ;               // compressed data
  331.         lpbiOutput              : PBITMAPINFOHEADER ;   // DIB to decompress to
  332.         lpOutput                : PVOID ;
  333.         ckid                    : DWORD ;               // ckid from AVI file
  334.     end;
  335.  
  336.     PICDECOMPRESSEX             = ^TICDECOMPRESSEX;
  337.     TICDECOMPRESSEX             = record
  338.  
  339.         //
  340.         // same as ICM_DECOMPRESS
  341.         //
  342.  
  343.         dwFlags                 : DWORD;
  344.         lpbiSrc                 : PBITMAPINFOHEADER;    // BITMAPINFO of compressed data
  345.         lpSrc                   : PVOID;                // compressed data
  346.         lpbiDst                 : PBITMAPINFOHEADER;    // DIB to decompress to
  347.         lpDst                   : PVOID;                // output data
  348.  
  349.         //
  350.         // new for ICM_DECOMPRESSEX
  351.         //
  352.  
  353.         xDst                    : int ; // destination rectangle
  354.         yDst                    : int ;
  355.         dxDst                   : int ;
  356.         dyDst                   : int ;
  357.  
  358.         xSrc                    : int ; // source rectangle
  359.         ySrc                    : int ;
  360.         dxSrc                   : int ;
  361.         dySrc                   : int ;
  362.     end;
  363.  
  364. {-----------------------------------------------------------------------------}
  365.  
  366. const
  367.     ICDRAW_QUERY                = $00000001 ; // test for support
  368.     ICDRAW_FULLSCREEN           = $00000002 ; // draw to full screen
  369.     ICDRAW_HDC                  = $00000004 ; // draw to a HDC/HWND
  370.     ICDRAW_ANIMATE              = $00000008 ;   // expect palette animation
  371.     ICDRAW_CONTINUE             = $00000010 ;   // draw is a continuation of previous draw
  372.     ICDRAW_MEMORYDC             = $00000020 ;   // DC is offscreen, by the way
  373.     ICDRAW_UPDATING             = $00000040 ;   // We're updating, as opposed to playing
  374.     ICDRAW_RENDER               = $00000080 ; // used to render data not draw it
  375.     ICDRAW_BUFFER               = $00000100 ; // please buffer this data offscreen, we will need to update it
  376.  
  377. type
  378.     PICDRAWBEGIN                = ^TICDRAWBEGIN;
  379.     TICDRAWBEGIN                = record
  380.         dwFlags                 : DWORD ;       // flags
  381.  
  382.         hpal                    : HPALETTE ;    // palette to draw with
  383.         hwnd                    : HWND ;        // window to draw to
  384.         hdc                     : HDC ;         // HDC to draw to
  385.  
  386.         xDst                    : int ;         // destination rectangle
  387.         yDst                    : int ;
  388.         dxDst                   : int ;
  389.         dyDst                   : int ;
  390.  
  391.         lpbi                    : PBITMAPINFOHEADER ;
  392.                                                 // format of frame to draw
  393.  
  394.         xSrc                    : int ;         // source rectangle
  395.         ySrc                    : int ;
  396.         dxSrc                   : int ;
  397.         dySrc                   : int ;
  398.  
  399.         dwRate                  : DWORD ;       // frames/second = (dwRate/dwScale)
  400.         dwScale                 : DWORD ;
  401.     end;
  402.  
  403. {-----------------------------------------------------------------------------}
  404.  
  405. const
  406.     ICDRAW_HURRYUP              = $80000000 ;   // don't draw just buffer (hurry up!)
  407.     ICDRAW_UPDATE               = $40000000 ;   // don't draw just update screen
  408.     ICDRAW_PREROLL              = $20000000 ;   // this frame is before real start
  409.     ICDRAW_NULLFRAME            = $10000000 ;   // repeat last frame
  410.     ICDRAW_NOTKEYFRAME          = $08000000 ;   // this frame is not a key frame
  411.  
  412. type
  413.     PICDRAW                     = ^TICDRAW;
  414.     TICDRAW                     = record
  415.         dwFlags                 : DWORD ;   // flags
  416.         lpFormat                : PVOID ;   // format of frame to decompress
  417.         lpData                  : PVOID ;   // frame data to decompress
  418.         cbData                  : DWORD ;
  419.         lTime                   : DWORD  ;   // time in drawbegin units (see dwRate and dwScale)
  420.     end;
  421.  
  422.     PICDRAWSUGGEST              = ^TICDRAWSUGGEST;
  423.     TICDRAWSUGGEST              = record
  424.         lpbiIn                  : PBITMAPINFOHEADER ;   // format to be drawn
  425.         lpbiSuggest             : PBITMAPINFOHEADER ;   // location for suggested format (or NULL to get size)
  426.         dxSrc                   : int ;                 // source extent or 0
  427.         dySrc                   : int ;
  428.         dxDst                   : int ;                 // dest extent or 0
  429.         dyDst                   : int ;
  430.         hicDecompressor         : HIC ;                 // decompressor you can talk to
  431.     end;
  432.  
  433. {-----------------------------------------------------------------------------}
  434.  
  435.     PICPALETTE                  = ^TICPALETTE;
  436.     TICPALETTE                  = record
  437.         dwFlags                 : DWORD ;           // flags (from AVI index...)
  438.         iStart                  : int ;             // first palette to change
  439.         iLen                    : int ;             // count of entries to change.
  440.         lppe                    : PPALETTEENTRY ;   // palette
  441.     end;
  442.  
  443. {-- ICM function declarations ------------------------------------------------}
  444.  
  445. function    ICInfo(fccType, fccHandler: DWORD; lpicinfo: PICINFO) : BOOL ; stdcall ;
  446. function    ICInstall(fccType, fccHandler: DWORD; lParam: LPARAM; szDesc: LPSTR; wFlags: UINT) : BOOL ; stdcall ;
  447. function    ICRemove(fccType, fccHandler: DWORD; wFlags: UINT) : BOOL ; stdcall ;
  448. function    ICGetInfo(hic: HIC; picinfo: PICINFO; cb: DWORD) : DWORD ; stdcall ;
  449.  
  450. function    ICOpen(fccType, fccHandler: DWORD; wMode: UINT) : HIC ; stdcall ;
  451. function    ICOpenFunction(fccType, fccHandler: DWORD; wMode: UINT; lpfnHandler: TFarProc) : HIC ; stdcall ;
  452. function    ICClose(hic: HIC) : DWORD; stdcall ;
  453.  
  454. function    ICSendMessage(hic: HIC; msg: UINT; dw1, dw2: DWORD) : DWORD ; stdcall ;
  455.  
  456. {-- Values for wFlags of ICInstall -------------------------------------------}
  457.  
  458. const
  459.     ICINSTALL_UNICODE           = $8000 ;
  460.  
  461.     ICINSTALL_FUNCTION          = $0001 ; // lParam is a DriverProc (function ptr)
  462.     ICINSTALL_DRIVER            = $0002 ; // lParam is a driver name (string)
  463.     ICINSTALL_HDRV              = $0004 ; // lParam is a HDRVR (driver handle)
  464.  
  465.     ICINSTALL_DRIVERW           = $8002 ; // lParam is a unicode driver name
  466.  
  467. {-- Query macros -------------------------------------------------------------}
  468.  
  469.     ICMF_CONFIGURE_QUERY        = $00000001 ;
  470.     ICMF_ABOUT_QUERY            = $00000001 ;
  471.  
  472. function    ICQueryAbout(hic: HIC): BOOL;
  473. function    ICAbout(hic: HIC; hwnd: HWND): DWORD;
  474. function    ICQueryConfigure(hic: HIC): BOOL;
  475. function    ICConfigure(hic: HIC; hwnd: HWND): DWORD;
  476.  
  477. {-- Get/Set state macros -----------------------------------------------------}
  478.  
  479. function    ICGetState(hic: HIC; pv: PVOID; cb: DWORD): DWORD;
  480. function    ICSetState(hic: HIC; pv: PVOID; cb: DWORD): DWORD;
  481. function    ICGetStateSize(hic: HIC): DWORD;
  482.  
  483. {-- Get value macros ---------------------------------------------------------}
  484.  
  485. function    ICGetDefaultQuality(hic: HIC): DWORD;
  486. function    ICGetDefaultKeyFrameRate(hic: HIC): DWORD;
  487.  
  488. {-- Draw window macro --------------------------------------------------------}
  489.  
  490. function    ICDrawWindow(hic: HIC; prc: PRECT): DWORD;
  491.  
  492. {== Compression functions ====================================================}
  493.  
  494. {-- ICCompress() - compress a single frame -----------------------------------}
  495.  
  496. function    ICCompress(
  497.     hic             : HIC;
  498.     dwFlags         : DWORD;                // flags
  499.     lpbiOutput      : PBITMAPINFOHEADER;    // output format
  500.     lpData          : PVOID;                // output data
  501.     lpbiInput       : PBITMAPINFOHEADER;    // format of frame to compress
  502.     lpBits          : PVOID;                // frame data to compress
  503.     lpckid          : PDWORD;               // ckid for data in AVI file
  504.     lpdwFlags       : PDWORD;               // flags in the AVI index.
  505.     lFrameNum       : DWORD;                 // frame number of seq.
  506.     dwFrameSize     : DWORD;                // reqested size in bytes. (if non zero)
  507.     dwQuality       : DWORD;                // quality within one frame
  508.     lpbiPrev        : PBITMAPINFOHEADER;    // format of previous frame
  509.     lpPrev          : PVOID                 // previous frame
  510.     ) : DWORD; cdecl;
  511.  
  512. {-- ICCompressBegin() - start compression from a source fmt to a dest fmt ----}
  513.  
  514. function    ICCompressBegin(hic: HIC; lpbiInput: PBITMAPINFOHEADER; lpbiOutput: PBITMAPINFOHEADER): DWORD;
  515.  
  516. {-- ICCompressQuery() - determines if compression from src to dst is supp ----}
  517.  
  518. function    ICCompressQuery(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  519.  
  520. {-- ICCompressGetFormat() - get the output format (fmt of compressed) --------}
  521.  
  522. // if lpbiOutput is nil return the size in bytes needed for format.
  523.  
  524. function    ICCompressGetFormat(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  525. function    ICCompressGetFormatSize(hic: HIC; lpbi: PBITMAPINFOHEADER): DWORD;
  526.  
  527. {-- ICCompressSize() - return the maximal size of a compressed frame ---------}
  528.  
  529. function    ICCompressGetSize(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  530. function    ICCompressEnd(hic: HIC): DWORD;
  531.  
  532. {== Decompression functions ==================================================}
  533.  
  534. {-- ICDecompress() - decompress a single frame -------------------------------}
  535.  
  536. function    ICDecompress(
  537.     hic             : HIC;
  538.     dwFlags         : DWORD;                // flags (from AVI index...)
  539.     lpbiFormat      : PBITMAPINFOHEADER;    // BITMAPINFO of compressed data
  540.                                             // biSizeImage has the chunk size
  541.     lpData          : PVOID;                // data
  542.     lpbi            : PBITMAPINFOHEADER;    // DIB to decompress to
  543.     lpBits          : PVOID
  544.     ): DWORD; cdecl;
  545.  
  546. {-- ICDecompressBegin() - start compression from src fmt to a dest fmt -------}
  547.  
  548. function    ICDecompressBegin(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  549.  
  550. {-- ICDecompressQuery() - determines if compression is supported -------------}
  551.  
  552. function    ICDecompressQuery(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  553.  
  554. {-- ICDecompressGetFormat - get the output fmt (fmt of uncompressed data) ----}
  555.  
  556. // if lpbiOutput is NULL return the size in bytes needed for format.
  557.  
  558. function    ICDecompressGetFormat(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  559. function    ICDecompressGetFormatSize(hic: HIC; lpbi: PBITMAPINFOHEADER): DWORD;
  560.  
  561. {-- ICDecompressGetPalette() - get the output palette ------------------------}
  562.  
  563. function    ICDecompressGetPalette(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  564. function    ICDecompressSetPalette(hic: HIC; lpbiPalette: PBITMAPINFOHEADER): DWORD;
  565.  
  566. function    ICDecompressEnd(hic: HIC): DWORD;
  567.  
  568. {== Decompression(ex) functions ==============================================}
  569.  
  570. //
  571. // on Win16 these functions are macros that call ICMessage. ICMessage will
  572. // not work on NT. rather than add new entrypoints we have given
  573. // them as static inline functions
  574. //
  575.  
  576. {-- ICDecompressEx() - decompress a single frame -----------------------------}
  577.  
  578. function    ICDecompressEx(
  579.     hic         : HIC;
  580.     dwFlags     : DWORD;
  581.     lpbiSrc     : PBITMAPINFOHEADER;
  582.     lpSrc       : PVOID;
  583.     xSrc        : int;
  584.     ySrc        : int;
  585.     dxSrc       : int;
  586.     dySrc       : int;
  587.     lpbiDst     : PBITMAPINFOHEADER;
  588.     lpDst       : PVOID;
  589.     xDst        : int;
  590.     yDst        : int;
  591.     dxDst       : int;
  592.     dyDst       : int
  593.     ): DWORD; stdcall;
  594.  
  595. {-- ICDecompressExBegin() - start compression from a src fmt to a dest fmt ---}
  596.  
  597. function    ICDecompressExBegin(
  598.     hic         : HIC;
  599.     dwFlags     : DWORD;
  600.     lpbiSrc     : PBITMAPINFOHEADER;
  601.     lpSrc       : PVOID;
  602.     xSrc        : int;
  603.     ySrc        : int;
  604.     dxSrc       : int;
  605.     dySrc       : int;
  606.     lpbiDst     : PBITMAPINFOHEADER;
  607.     lpDst       : PVOID;
  608.     xDst        : int;
  609.     yDst        : int;
  610.     dxDst       : int;
  611.     dyDst       : int
  612.     ): DWORD; stdcall;
  613.  
  614. {-- ICDecompressExQuery() ----------------------------------------------------}
  615.  
  616. function    ICDecompressExQuery(
  617.     hic         : HIC;
  618.     dwFlags     : DWORD;
  619.     lpbiSrc     : PBITMAPINFOHEADER;
  620.     lpSrc       : PVOID;
  621.     xSrc        : int;
  622.     ySrc        : int;
  623.     dxSrc       : int;
  624.     dySrc       : int;
  625.     lpbiDst     : PBITMAPINFOHEADER;
  626.     lpDst       : PVOID;
  627.     xDst        : int;
  628.     yDst        : int;
  629.     dxDst       : int;
  630.     dyDst       : int
  631.     ): DWORD; stdcall;
  632.  
  633. function    ICDecompressExEnd(hic: HIC): DWORD;
  634.  
  635. {== Drawing functions ========================================================}
  636.  
  637. {-- ICDrawBegin() - start decompressing data with fmt directly to screen -----}
  638.  
  639. // return zero if the decompressor supports drawing.
  640.  
  641. function    ICDrawBegin(
  642.     hic         : HIC;
  643.     dwFlags     : DWORD;                // flags
  644.     hpal        : HPALETTE;             // palette to draw with
  645.     hwnd        : HWND;                 // window to draw to
  646.     hdc         : HDC;                  // HDC to draw to
  647.     xDst        : int;                  // destination rectangle
  648.     yDst        : int;
  649.     dxDst       : int;
  650.     dyDst       : int;
  651.     lpbi        : PBITMAPINFOHEADER;    // format of frame to draw
  652.     xSrc        : int;                  // source rectangle
  653.     ySrc        : int;
  654.     dxSrc       : int;
  655.     dySrc       : int;
  656.     dwRate      : DWORD;                // frames/second = (dwRate/dwScale)
  657.     dwScale     : DWORD
  658.     ): DWORD; cdecl;
  659.  
  660. {-- ICDraw() - decompress data directly to the screen ------------------------}
  661.  
  662. function    ICDraw(
  663.     hic         : HIC;
  664.     dwFlags     : DWORD;                // flags
  665.     lpFormat    : PVOID;                // format of frame to decompress
  666.     lpData      : PVOID;                // frame data to decompress
  667.     cbData      : DWORD;                // size of data
  668.     lTime       : DWORD                  // time to draw this frame
  669.     ): DWORD; cdecl;
  670.  
  671. // ICMessage is not supported on Win32, so provide a static inline function
  672. // to do the same job
  673.  
  674. function    ICDrawSuggestFormat(
  675.     hic         : HIC;
  676.     lpbiIn      : PBITMAPINFOHEADER;
  677.     lpbiOut     : PBITMAPINFOHEADER;
  678.     dxSrc       : int;
  679.     dySrc       : int;
  680.     dxDst       : int;
  681.     dyDst       : int;
  682.     hicDecomp   : HIC
  683.     ): DWORD; stdcall;
  684.  
  685. {-- ICDrawQuery() - determines if the compressor is willing to render fmt ----}
  686.  
  687. function    ICDrawQuery(hic: HIC; lpbiInput: PBITMAPINFOHEADER): DWORD;
  688. function    ICDrawChangePalette(hic: HIC; lpbiInput: PBITMAPINFOHEADER): DWORD;
  689. function    ICGetBuffersWanted(hic: HIC; lpdwBuffers: PDWORD): DWORD;
  690. function    ICDrawEnd(hic: HIC): DWORD;
  691. function    ICDrawStart(hic: HIC): DWORD;
  692. function    ICDrawStartPlay(hic: HIC; lFrom, lTo: DWORD): DWORD;
  693. function    ICDrawStop(hic: HIC): DWORD;
  694. function    ICDrawStopPlay(hic: HIC): DWORD;
  695. function    ICDrawGetTime(hic: HIC; lplTime: PDWORD): DWORD;
  696. function    ICDrawSetTime(hic: HIC; lTime: DWORD): DWORD;
  697. function    ICDrawRealize(hic: HIC; hdc: HDC; fBackground: BOOL): DWORD;
  698. function    ICDrawFlush(hic: HIC): DWORD;
  699. function    ICDrawRenderBuffer(hic: HIC): DWORD;
  700.  
  701. {== Status callback functions ================================================}
  702.  
  703. {-- ICSetStatusProc() - Set the status callback function ---------------------}
  704.  
  705. // ICMessage is not supported on NT
  706.  
  707. function    ICSetStatusProc(
  708.     hic         : HIC;
  709.     dwFlags     : DWORD;
  710.     lParam      : DWORD;
  711.     fpfnStatus  : TICStatusProc
  712.     ): DWORD; stdcall;
  713.  
  714. {== Helper routines for DrawDib and MCIAVI... ================================}
  715.  
  716. function    ICLocate(fccType, fccHandler: DWORD; lpbiIn, lpbiOut: PBITMAPINFOHEADER; wFlags: WORD): HIC; stdcall;
  717. function    ICGetDisplayFormat(hic: HIC; lpbiIn, lpbiOut: PBITMAPINFOHEADER; BitDepth: int; dx, dy: int): HIC; stdcall;
  718.  
  719. function    ICDecompressOpen(fccType, fccHandler: DWORD; lpbiIn, lpbiOut: PBITMAPINFOHEADER): HIC;
  720. function    ICDrawOpen(fccType, fccHandler: DWORD; lpbiIn: PBITMAPINFOHEADER): HIC;
  721.  
  722. {== Higher level functions ===================================================}
  723.  
  724. function    ICImageCompress(
  725.     hic         : HIC;                  // compressor to use
  726.     uiFlags     : UINT;                 // flags (none yet)
  727.     lpbiIn      : PBITMAPINFO;          // format to compress from
  728.     lpBits      : PVOID;                // data to compress
  729.     lpbiOut     : PBITMAPINFO;          // compress to this (NULL ==> default)
  730.     lQuality    : DWORD;                 // quality to use
  731.     plSize      : PDWORD                 // compress to this size (0=whatever)
  732.     ): THANDLE; stdcall;
  733.  
  734. function    ICImageDecompress(
  735.     hic         : HIC;                  // compressor to use
  736.     uiFlags     : UINT;                 // flags (none yet)
  737.     lpbiIn      : PBITMAPINFO;          // format to decompress from
  738.     lpBits      : PVOID;                // data to decompress
  739.     lpbiOut     : PBITMAPINFO           // decompress to this (NULL ==> default)
  740.     ): THANDLE; stdcall;
  741.  
  742. {-- TCompVars ----------------------------------------------------------------}
  743.     
  744. //
  745. // Structure used by ICSeqCompressFrame and ICCompressorChoose routines
  746. // Make sure this matches the autodoc in icm.c!
  747. //
  748.  
  749. type
  750.     PCOMPVARS       = ^TCOMPVARS;
  751.     TCOMPVARS       = record
  752.         cbSize      : DWORD;             // set to sizeof(COMPVARS) before
  753.                                         // calling ICCompressorChoose
  754.         dwFlags     : DWORD;            // see below...
  755.         hic         : HIC;              // HIC of chosen compressor
  756.         fccType     : DWORD;            // basically ICTYPE_VIDEO
  757.         fccHandler  : DWORD;            // handler of chosen compressor or
  758.                                         // "" or "DIB "
  759.         lpbiIn      : PBITMAPINFO;      // input format
  760.         lpbiOut     : PBITMAPINFO;      // output format - will compress to this
  761.         lpBitsOut   : PVOID;
  762.         lpBitsPrev  : PVOID;
  763.         lFrame      : DWORD;
  764.         lKey        : DWORD;             // key frames how often?
  765.         lDataRate   : DWORD;             // desired data rate KB/Sec
  766.         lQ          : DWORD;             // desired quality
  767.         lKeyCount   : DWORD;
  768.         lpState     : PVOID;            // state of compressor
  769.         cbState     : DWORD;             // size of the state
  770.     end;
  771.  
  772. // FLAGS for dwFlags element of COMPVARS structure:
  773. // set this flag if you initialize COMPVARS before calling ICCompressorChoose
  774.  
  775. const
  776.     ICMF_COMPVARS_VALID         = $00000001;    // COMPVARS contains valid data
  777.  
  778. {-- ICCompressorChoose() - allows user to choose compressor, quality etc... --}
  779.  
  780. function    ICCompressorChoose(
  781.     hwnd        : HWND;                     // parent window for dialog
  782.     uiFlags     : UINT;                     // flags
  783.     pvIn        : PVOID;                    // input format (optional)
  784.     lpData      : PVOID;                    // input data (optional)
  785.     pc          : PCOMPVARS;                // data about the compressor/dlg
  786.     lpszTitle   : LPSTR                     // dialog title (optional)
  787.     ): BOOL; stdcall;
  788.  
  789. // defines for uiFlags
  790.  
  791. const
  792.     ICMF_CHOOSE_KEYFRAME        = $0001;    // show KeyFrame Every box
  793.     ICMF_CHOOSE_DATARATE        = $0002;    // show DataRate box
  794.     ICMF_CHOOSE_PREVIEW         = $0004;    // allow expanded preview dialog
  795.     ICMF_CHOOSE_ALLCOMPRESSORS  = $0008;    // don't only show those that
  796.                                             // can handle the input format
  797.                                             // or input data
  798.  
  799. function    ICSeqCompressFrameStart(pc: PCOMPVARS; lpbiIn: PBITMAPINFO): BOOL; stdcall;
  800. procedure   ICSeqCompressFrameEnd(pc: PCOMPVARS); stdcall;
  801.  
  802. function    ICSeqCompressFrame(
  803.     pc          : PCOMPVARS;                // set by ICCompressorChoose
  804.     uiFlags     : UINT;                     // flags
  805.     lpBits      : PVOID;                    // input DIB bits
  806.     pfKey       : PBOOL;                    // did it end up being a key frame?
  807.     plSize      : PDWORD                     // size to compress to/of returned image
  808.     ): PVOID; stdcall;
  809.  
  810. procedure   ICCompressorFree(pc: PCOMPVARS); stdcall;
  811.  
  812. {== DRAWDIB - Routines for drawing to the display ============================}
  813.  
  814. type
  815.     HDRAWDIB                    = THandle;  // hdd
  816.  
  817. {== DrawDib Flags ============================================================}
  818.  
  819. const
  820.     DDF_UPDATE                  = $0002;    // re-draw the last DIB
  821.     DDF_SAME_HDC                = $0004;    // HDC same as last call (all setup)
  822.     DDF_SAME_DRAW               = $0008;    // draw params are the same
  823.     DDF_DONTDRAW                = $0010;    // dont draw frame, just decompress
  824.     DDF_ANIMATE                 = $0020;    // allow palette animation
  825.     DDF_BUFFER                  = $0040;    // always buffer image
  826.     DDF_JUSTDRAWIT              = $0080;    // just draw it with GDI
  827.     DDF_FULLSCREEN              = $0100;    // use DisplayDib
  828.     DDF_BACKGROUNDPAL           = $0200;    // Realize palette in background
  829.     DDF_NOTKEYFRAME             = $0400;    // this is a partial frame update, hint
  830.     DDF_HURRYUP                 = $0800;    // hurry up please!
  831.     DDF_HALFTONE                = $1000;    // always halftone
  832.  
  833.     DDF_PREROLL                 = DDF_DONTDRAW; // Builing up a non-keyframe
  834.     DDF_SAME_DIB                = DDF_SAME_DRAW;
  835.     DDF_SAME_SIZE               = DDF_SAME_DRAW;
  836.  
  837. {== DrawDib functions ========================================================}
  838.  
  839. {-- DrawDibOpen() ------------------------------------------------------------}
  840.  
  841. function    DrawDibOpen: HDRAWDIB; stdcall;
  842.  
  843. {-- DrawDibClose() -----------------------------------------------------------}
  844.  
  845. function    DrawDibClose(hdd: HDRAWDIB): BOOL; stdcall;
  846.  
  847. {-- DrawDibGetBuffer() -------------------------------------------------------}
  848.  
  849. function    DrawDibGetBuffer(hdd: HDRAWDIB; lpbi: PBITMAPINFOHEADER; dwSize: DWORD; dwFlags: DWORD): PVOID; stdcall; 
  850.  
  851. {-- DrawDibGetPalette() - get the palette used for drawing DIBs --------------}
  852.  
  853. function    DrawDibGetPalette(hdd: HDRAWDIB): HPALETTE; stdcall;
  854.  
  855. {-- DrawDibSetPalette() - set the palette used for drawing DIBs --------------}
  856.  
  857. function    DrawDibSetPalette(hdd: HDRAWDIB; hpal: HPALETTE): BOOL; stdcall;
  858.  
  859. {-- DrawDibChangePalette() ---------------------------------------------------}
  860.  
  861. function    DrawDibChangePalette(hdd: HDRAWDIB; iStart, iLen: int; lppe: PPALETTEENTRY): BOOL; stdcall;
  862.  
  863. {-- DrawDibRealize() - realize the palette in a HDD --------------------------}
  864.  
  865. function    DrawDibRealize(hdd: HDRAWDIB; hdc: HDC; fBackground: BOOL): UINT; stdcall;
  866.  
  867. {-- DrawDibStart() - start of streaming playback -----------------------------}
  868.  
  869. function    DrawDibStart(hdd: HDRAWDIB; rate: DWORD): BOOL; stdcall;
  870.  
  871. {-- DrawDibStop() - start of streaming playback ------------------------------}
  872.  
  873. function    DrawDibStop(hdd: HDRAWDIB): BOOL; stdcall;
  874.  
  875. {-- DrawDibBegin() - prepare to draw -----------------------------------------}
  876.  
  877. function    DrawDibBegin(
  878.     hdd         : HDRAWDIB;
  879.     hdc         : HDC;
  880.     dxDst       : int;
  881.     dyDst       : int;
  882.     lpbi        : PBITMAPINFOHEADER;
  883.     dxSrc       : int;
  884.     dySrc       : int;
  885.     wFlags      : UINT
  886.     ): BOOL; stdcall;
  887.  
  888. {-- DrawDibDraw() - actually draw a DIB to the screen ------------------------}
  889.  
  890. function    DrawDibDraw(
  891.     hdd         : HDRAWDIB;
  892.     hdc         : HDC;
  893.     xDst        : int;
  894.     yDst        : int;
  895.     dxDst       : int;
  896.     dyDst       : int;
  897.     lpbi        : PBITMAPINFOHEADER;
  898.     lpBits      : PVOID;
  899.     xSrc        : int;
  900.     ySrc        : int;
  901.     dxSrc       : int;
  902.     dySrc       : int;
  903.     wFlags      : UINT
  904.     ): BOOL; stdcall;
  905.  
  906. {-- DrawDibUpdate() - redraw last image (may only be valid with DDF_BUFFER) --}
  907.  
  908. function    DrawDibUpdate(hdd: HDRAWDIB; hdc: HDC; x, y: int): BOOL;
  909.  
  910. {-- DrawDibEnd() -------------------------------------------------------------}
  911.  
  912. function    DrawDibEnd(hdd: HDRAWDIB): BOOL; stdcall;
  913.  
  914. {-- DrawDibTime() - for debugging purposes only ------------------------------}
  915.  
  916. type
  917.     PDRAWDIBTIME        = ^TDRAWDIBTIME;
  918.     TDRAWDIBTIME        = record
  919.         timeCount       : DWORD;
  920.         timeDraw        : DWORD;
  921.         timeDecompress  : DWORD;
  922.         timeDither      : DWORD;
  923.         timeStretch     : DWORD;
  924.         timeBlt         : DWORD;
  925.         timeSetDIBits   : DWORD;
  926.     end;
  927.  
  928. function    DrawDibTime(hdd: HDRAWDIB; lpddtime: PDRAWDIBTIME): BOOL; stdcall;
  929.  
  930. {-- Display profiling --------------------------------------------------------}
  931.  
  932. const
  933.     PD_CAN_DRAW_DIB             = $0001;    // if you can draw at all
  934.     PD_CAN_STRETCHDIB           = $0002;    // basicly RC_STRETCHDIB
  935.     PD_STRETCHDIB_1_1_OK        = $0004;    // is it fast?
  936.     PD_STRETCHDIB_1_2_OK        = $0008;    // ...
  937.     PD_STRETCHDIB_1_N_OK        = $0010;    // ...
  938.  
  939. function    DrawDibProfileDisplay(lpbi: PBITMAPINFOHEADER): DWORD; stdcall;
  940.  
  941. {== AVIFMT - AVI file format definitions =====================================}
  942.  
  943. //
  944. // The following is a short description of the AVI file format.  Please
  945. // see the accompanying documentation for a full explanation.
  946. //
  947. // An AVI file is the following RIFF form:
  948. //
  949. //  RIFF('AVI' 
  950. //        LIST('hdrl'
  951. //          avih(<MainAVIHeader>)
  952. //                  LIST ('strl'
  953. //                      strh(<Stream header>)
  954. //                      strf(<Stream format>)
  955. //                      ... additional header data
  956. //            LIST('movi'    
  957. //            { LIST('rec' 
  958. //                    SubChunk...
  959. //                 )
  960. //                | SubChunk } ....
  961. //            )
  962. //            [ <AVIIndex> ]
  963. //      )
  964. //
  965. //  The main file header specifies how many streams are present.  For
  966. //  each one, there must be a stream header chunk and a stream format
  967. //  chunk, enlosed in a 'strl' LIST chunk.  The 'strf' chunk contains
  968. //  type-specific format information; for a video stream, this should
  969. //  be a BITMAPINFO structure, including palette.  For an audio stream,
  970. //  this should be a WAVEFORMAT (or PCMWAVEFORMAT) structure.
  971. //
  972. //  The actual data is contained in subchunks within the 'movi' LIST 
  973. //  chunk.  The first two characters of each data chunk are the
  974. //  stream number with which that data is associated.
  975. //
  976. //  Some defined chunk types:
  977. //           Video Streams:
  978. //                  ##db:   RGB DIB bits
  979. //                  ##dc:   RLE8 compressed DIB bits
  980. //                  ##pc:   Palette Change
  981. //
  982. //           Audio Streams:
  983. //                  ##wb:   waveform audio bytes
  984. //
  985. // The grouping into LIST 'rec' chunks implies only that the contents of
  986. //   the chunk should be read into memory at the same time.  This
  987. //   grouping is used for files specifically intended to be played from 
  988. //   CD-ROM.
  989. //
  990. // The index chunk at the end of the file should contain one entry for 
  991. //   each data chunk in the file.
  992. //
  993. // Limitations for the current software:
  994. //  Only one video stream and one audio stream are allowed.
  995. //  The streams must start at the beginning of the file.
  996. //
  997. //
  998. // To register codec types please obtain a copy of the Multimedia
  999. // Developer Registration Kit from:
  1000. //
  1001. //  Microsoft Corporation
  1002. //  Multimedia Systems Group
  1003. //  Product Marketing
  1004. //  One Microsoft Way
  1005. //  Redmond, WA 98052-6399
  1006. //
  1007.  
  1008. {-- form types, list types and chunk types -----------------------------------}
  1009.  
  1010. const
  1011.     formtypeAVI                 = $20495641; // mmioFOURCC('A', 'V', 'I', ' ')
  1012.     listtypeAVIHEADER           = $6C726468; // mmioFOURCC('h', 'd', 'r', 'l')
  1013.     ckidAVIMAINHDR              = $68697661; // mmioFOURCC('a', 'v', 'i', 'h')
  1014.     listtypeSTREAMHEADER        = $6C727473; // mmioFOURCC('s', 't', 'r', 'l')
  1015.     ckidSTREAMHEADER            = $68727473; // mmioFOURCC('s', 't', 'r', 'h')
  1016.     ckidSTREAMFORMAT            = $66727473; // mmioFOURCC('s', 't', 'r', 'f')
  1017.     ckidSTREAMHANDLERDATA       = $64727473; // mmioFOURCC('s', 't', 'r', 'd')
  1018.     ckidSTREAMNAME              = $6E727473; // mmioFOURCC('s', 't', 'r', 'n')
  1019.  
  1020.     listtypeAVIMOVIE            = $69766F6D; // mmioFOURCC('m', 'o', 'v', 'i')
  1021.     listtypeAVIRECORD           = $20636572; // mmioFOURCC('r', 'e', 'c', ' ')
  1022.  
  1023.     ckidAVINEWINDEX             = $31786469; // mmioFOURCC('i', 'd', 'x', '1')
  1024.  
  1025. {-- Stream types for the <fccType> field of the stream header ----------------}
  1026.  
  1027.     streamtypeVIDEO             = $73646976; // mmioFOURCC('v', 'i', 'd', 's')
  1028.     streamtypeAUDIO             = $73647561; // mmioFOURCC('a', 'u', 'd', 's')
  1029.     streamtypeMIDI              = $7364696D; // mmioFOURCC('m', 'i', 'd', 's')
  1030.     streamtypeTEXT              = $73747874; // mmioFOURCC('t', 'x', 't', 's')
  1031.  
  1032. {-- Basic chunk types --------------------------------------------------------}
  1033.  
  1034.     cktypeDIBbits               = $6264; // aviTWOCC('d', 'b')
  1035.     cktypeDIBcompressed         = $6364; // aviTWOCC('d', 'c')
  1036.     cktypePALchange             = $6370; // aviTWOCC('p', 'c')
  1037.     cktypeWAVEbytes             = $6277; // aviTWOCC('w', 'b')
  1038.  
  1039. {-- Chunk id to use for extra chunks for padding -----------------------------}
  1040.  
  1041.     ckidAVIPADDING              = $4B4E554A; // mmioFOURCC('J', 'U', 'N', 'K')
  1042.  
  1043. {== Useful macros ============================================================}
  1044.  
  1045. {-- Macro to get stream number out of a FOURCC ckid --------------------------}
  1046.  
  1047. function    FromHex(n: BYTE): BYTE;
  1048. function    StreamFromFOURCC(fcc: DWORD): BYTE;
  1049.  
  1050. {-- Macro to get TWOCC chunk type out of a FOURCC ckid -----------------------}
  1051.  
  1052. function    TWOCCFromFOURCC(fcc: DWORD): WORD;
  1053.  
  1054. {-- Macro to make a ckid for a chunk out of a TWOCC and a stream num (0-255) -}
  1055.  
  1056. function    ToHex(n: BYTE): BYTE;
  1057. function    MAKEAVICKID(tcc: WORD; stream: BYTE): DWORD;
  1058.  
  1059. {-- Main AVI file header -----------------------------------------------------}
  1060.  
  1061. {-- flags for use in <dwFlags> in AVIFileHdr ---------------------------------}
  1062.  
  1063. const
  1064.     AVIF_HASINDEX               = $00000010;    // Index at end of file?
  1065.     AVIF_MUSTUSEINDEX           = $00000020;
  1066.     AVIF_ISINTERLEAVED          = $00000100;
  1067.     AVIF_TRUSTCKTYPE            = $00000800;    // Use CKType to find key frames?
  1068.     AVIF_WASCAPTUREFILE         = $00010000;
  1069.     AVIF_COPYRIGHTED            = $00020000;
  1070.  
  1071. {-- The AVI File Header LIST chunk should be padded to this size -------------}
  1072.  
  1073. const
  1074.     AVI_HEADERSIZE              = 2048;         // size of AVI header list
  1075.  
  1076. type
  1077.     PMainAVIHeader              = ^TMainAVIHeader;
  1078.     TMainAVIHeader              = record
  1079.         dwMicroSecPerFrame      : DWORD;        // frame display rate (or 0L)
  1080.         dwMaxBytesPerSec        : DWORD;        // max. transfer rate
  1081.         dwPaddingGranularity    : DWORD;        // pad to multiples of this
  1082.                                                 // size; normally 2K.
  1083.         dwFlags                 : DWORD;        // the ever-present flags
  1084.         dwTotalFrames           : DWORD;        // # frames in file
  1085.         dwInitialFrames         : DWORD;
  1086.         dwStreams               : DWORD;
  1087.         dwSuggestedBufferSize   : DWORD;
  1088.  
  1089.         dwWidth                 : DWORD;
  1090.         dwHeight                : DWORD;
  1091.  
  1092.         dwReserved              : array[0..3] of DWORD;
  1093.     end;
  1094.  
  1095. {-- Stream header ------------------------------------------------------------}
  1096.  
  1097. const
  1098.     AVISF_DISABLED              = $00000001;
  1099.  
  1100.     AVISF_VIDEO_PALCHANGES      = $00010000;
  1101.  
  1102. type
  1103.     PAVIStreamHeader            = ^TAVIStreamHeader;
  1104.     TAVIStreamHeader            = record
  1105.         fccType                 : FOURCC;
  1106.         fccHandler              : FOURCC;
  1107.         dwFlags                 : DWORD;        // Contains AVITF_* flags
  1108.         wPriority               : WORD;
  1109.         wLanguage               : WORD;
  1110.         dwInitialFrames         : DWORD;
  1111.         dwScale                 : DWORD;
  1112.         dwRate                  : DWORD;        // dwRate / dwScale == samples/second
  1113.         dwStart                 : DWORD;
  1114.         dwLength                : DWORD;        // In units above...
  1115.         dwSuggestedBufferSize   : DWORD;
  1116.         dwQuality               : DWORD;
  1117.         dwSampleSize            : DWORD;
  1118.         rcFrame                 : TRECT;
  1119.     end;
  1120.  
  1121. {-- Flags for index ----------------------------------------------------------}
  1122.  
  1123. const
  1124.     AVIIF_NOTIME                = $00000100;    // this frame doesn't take any time
  1125.     AVIIF_COMPUSE               = $0FFF0000;    // these bits are for compressor use
  1126.  
  1127. type
  1128.     PAVIINDEXENTRY              = ^TAVIINDEXENTRY;
  1129.     TAVIINDEXENTRY              = record
  1130.         ckid                    : DWORD;
  1131.         dwFlags                 : DWORD;
  1132.         dwChunkOffset           : DWORD;        // Position of chunk
  1133.         dwChunkLength           : DWORD;        // Length of chunk
  1134.     end;
  1135.  
  1136. {-- Palette change chunk (used in video streams) -----------------------------}
  1137.  
  1138.     PAVIPALCHANGE               = ^TAVIPALCHANGE;
  1139.     TAVIPALCHANGE               = record
  1140.         bFirstEntry             : BYTE;         // first entry to change
  1141.         bNumEntries             : BYTE;         // # entries to change (0 if 256)
  1142.         wFlags                  : WORD;         // Mostly to preserve alignment...
  1143.         // peNew                : array[0..-1] of PALETTEENTRY ;
  1144.                                                 // New color specifications
  1145.     end;
  1146.  
  1147. {== AVIFile - routines for reading/writing standard AVI files ================}
  1148.  
  1149. //
  1150. // Ansi - Unicode thunking.
  1151. //
  1152. // Unicode or Ansi-only apps can call the avifile APIs.
  1153. // any Win32 app who wants to use
  1154. // any of the AVI COM interfaces must be UNICODE - the AVISTREAMINFO and
  1155. // AVIFILEINFO structures used in the Info methods of these interfaces are
  1156. // the unicode variants, and no thunking to or from ansi takes place
  1157. // except in the AVIFILE api entrypoints.
  1158. //
  1159. // For Ansi/Unicode thunking: for each entrypoint or structure that
  1160. // uses chars or strings, two versions are declared in the Win32 version,
  1161. // ApiNameW and ApiNameA. The default name ApiName is #defined to one or
  1162. // other of these depending on whether UNICODE is defined (during
  1163. // compilation of the app that is including this header). The source will
  1164. // contain ApiName and ApiNameA (with ApiName being the Win16 implementation,
  1165. // and also #defined to ApiNameW, and ApiNameA being the thunk entrypoint).
  1166. //
  1167.  
  1168. // For GetFrame::SetFormat - use the best format for the display
  1169.  
  1170. const
  1171.     AVIGETFRAMEF_BESTDISPLAYFMT = 1;
  1172.  
  1173. //
  1174. // Structures used by AVIStreamInfo & AVIFileInfo.
  1175. //
  1176. // These are related to, but not identical to, the header chunks
  1177. // in an AVI file.
  1178. //
  1179.  
  1180. {-- AVISTREAMINFO ------------------------------------------------------------}
  1181.  
  1182. // for Unicode/Ansi thunking we need to declare three versions of this!
  1183.  
  1184. type
  1185.     PAVISTREAMINFOW             = ^TAVISTREAMINFOW;
  1186.     TAVISTREAMINFOW             = record
  1187.         fccType                 : DWORD;
  1188.         fccHandler              : DWORD;
  1189.         dwFlags                 : DWORD;        // Contains AVITF_* flags
  1190.         dwCaps                  : DWORD;
  1191.         wPriority               : WORD;
  1192.         wLanguage               : WORD;
  1193.         dwScale                 : DWORD;
  1194.         dwRate                  : DWORD;        // dwRate / dwScale == samples/second
  1195.         dwStart                 : DWORD;
  1196.         dwLength                : DWORD;        // In units above...
  1197.         dwInitialFrames         : DWORD;
  1198.         dwSuggestedBufferSize   : DWORD;
  1199.         dwQuality               : DWORD;
  1200.         dwSampleSize            : DWORD;
  1201.         rcFrame                 : TRECT ;
  1202.         dwEditCount             : DWORD;
  1203.         dwFormatChangeCount     : DWORD;
  1204.         szName                  : array[0..63] of WideChar;
  1205.     end;
  1206.  
  1207.     PAVISTREAMINFOA             = ^TAVISTREAMINFOA;
  1208.     TAVISTREAMINFOA             = record
  1209.         fccType                 : DWORD;
  1210.         fccHandler              : DWORD;
  1211.         dwFlags                 : DWORD;        // Contains AVITF_* flags
  1212.         dwCaps                  : DWORD;
  1213.         wPriority               : WORD;
  1214.         wLanguage               : WORD;
  1215.         dwScale                 : DWORD;
  1216.         dwRate                  : DWORD;        // dwRate / dwScale == samples/second
  1217.         dwStart                 : DWORD;
  1218.         dwLength                : DWORD;        // In units above...
  1219.         dwInitialFrames         : DWORD;
  1220.         dwSuggestedBufferSize   : DWORD;
  1221.         dwQuality               : DWORD;
  1222.         dwSampleSize            : DWORD;
  1223.         rcFrame                 : TRECT ;
  1224.         dwEditCount             : DWORD;
  1225.         dwFormatChangeCount     : DWORD;
  1226.         szName                  : array[0..63] of AnsiChar;
  1227.     end;
  1228.  
  1229.     TAVISTREAMINFO              = TAVISTREAMINFOA;
  1230.     PAVISTREAMINFO              = PAVISTREAMINFOA;
  1231.  
  1232. const
  1233.     AVISTREAMINFO_DISABLED      = $00000001;
  1234.     AVISTREAMINFO_FORMATCHANGES = $00010000;
  1235.  
  1236. {-- AVIFILEINFO --------------------------------------------------------------}
  1237.  
  1238. type
  1239.     PAVIFILEINFOW               = ^TAVIFILEINFOW;
  1240.     TAVIFILEINFOW               = record
  1241.         dwMaxBytesPerSec        : DWORD;        // max. transfer rate
  1242.         dwFlags                 : DWORD;        // the ever-present flags
  1243.         dwCaps                  : DWORD;
  1244.         dwStreams               : DWORD;
  1245.         dwSuggestedBufferSize   : DWORD;
  1246.  
  1247.         dwWidth                 : DWORD;
  1248.         dwHeight                : DWORD;
  1249.  
  1250.         dwScale                 : DWORD;
  1251.         dwRate                  : DWORD;        // dwRate / dwScale == samples/second
  1252.         dwLength                : DWORD;
  1253.  
  1254.         dwEditCount             : DWORD;
  1255.  
  1256.         szFileType              : array[0..63] of WideChar;
  1257.                                                 // descriptive string for file type?
  1258.     end;
  1259.  
  1260.     PAVIFILEINFOA               = ^TAVIFILEINFOA;
  1261.     TAVIFILEINFOA               = record
  1262.         dwMaxBytesPerSec        : DWORD;        // max. transfer rate
  1263.         dwFlags                 : DWORD;        // the ever-present flags
  1264.         dwCaps                  : DWORD;
  1265.         dwStreams               : DWORD;
  1266.         dwSuggestedBufferSize   : DWORD;
  1267.  
  1268.         dwWidth                 : DWORD;
  1269.         dwHeight                : DWORD;
  1270.  
  1271.         dwScale                 : DWORD;
  1272.         dwRate                  : DWORD;        // dwRate / dwScale == samples/second
  1273.         dwLength                : DWORD;
  1274.  
  1275.         dwEditCount             : DWORD;
  1276.  
  1277.         szFileType              : array[0..63] of AnsiChar;
  1278.                                                 // descriptive string for file type?
  1279.     end;
  1280.  
  1281.     TAVIFILEINFO                    = TAVIFILEINFOA;
  1282.     PAVIFILEINFO                    = PAVIFILEINFOA;
  1283.  
  1284. {-- Flags for dwFlags --------------------------------------------------------}
  1285.  
  1286. const
  1287.     AVIFILEINFO_HASINDEX            = $00000010;
  1288.     AVIFILEINFO_MUSTUSEINDEX        = $00000020;
  1289.     AVIFILEINFO_ISINTERLEAVED       = $00000100;
  1290.     AVIFILEINFO_WASCAPTUREFILE      = $00010000;
  1291.     AVIFILEINFO_COPYRIGHTED         = $00020000;
  1292.  
  1293. {-- Flags for dwCaps ---------------------------------------------------------}
  1294.  
  1295.     AVIFILECAPS_CANREAD             = $00000001;
  1296.     AVIFILECAPS_CANWRITE            = $00000002;
  1297.     AVIFILECAPS_ALLKEYFRAMES        = $00000010;
  1298.     AVIFILECAPS_NOCOMPRESSION       = $00000020;
  1299.  
  1300. type
  1301.     TAVISAVECALLBACK                = function(i: int): BOOL; pascal;
  1302.  
  1303. {-- AVICOMPRESSOPTIONS -------------------------------------------------------}
  1304.  
  1305. // Make sure it matches the AutoDoc in avisave.c !!!
  1306.  
  1307. type
  1308.     PAVICOMPRESSOPTIONS             = ^TAVICOMPRESSOPTIONS;
  1309.     TAVICOMPRESSOPTIONS             = record
  1310.         fccType                     : DWORD;    // stream type, for consistency
  1311.         fccHandler                  : DWORD;    // compressor
  1312.         dwKeyFrameEvery             : DWORD;    // keyframe rate
  1313.         dwQuality                   : DWORD;    // compress quality 0-10,000
  1314.         dwBytesPerSecond            : DWORD;    // bytes per second
  1315.         dwFlags                     : DWORD;    // flags... see below
  1316.         lpFormat                    : PVOID;    // save format
  1317.         cbFormat                    : DWORD;
  1318.         lpParms                     : PVOID;    // compressor options
  1319.         cbParms                     : DWORD;
  1320.         dwInterleaveEvery           : DWORD;    // for non-video streams only
  1321.     end;
  1322.  
  1323. //
  1324. // Defines for the dwFlags field of the AVICOMPRESSOPTIONS struct
  1325. // Each of these flags determines if the appropriate field in the structure
  1326. // (dwInterleaveEvery, dwBytesPerSecond, and dwKeyFrameEvery) is payed
  1327. // attention to.  See the autodoc in avisave.c for details.
  1328. //
  1329.  
  1330. const
  1331.     AVICOMPRESSF_INTERLEAVE         = $00000001;    // interleave
  1332.     AVICOMPRESSF_DATARATE           = $00000002;    // use a data rate
  1333.     AVICOMPRESSF_KEYFRAMES          = $00000004;    // use keyframes
  1334.     AVICOMPRESSF_VALID              = $00000008;    // has valid data?
  1335.  
  1336. {== AVI interfaces ===========================================================}
  1337.  
  1338. {-- AVIStream ----------------------------------------------------------------}
  1339.  
  1340. type
  1341.     PAVIStream      = ^IAVIStream;
  1342.     IAVIStream      = class(IUnknown)
  1343.     public
  1344.         function    Create(lParam1, lParam2: LPARAM): HResult; virtual; stdcall; abstract;
  1345.         function    Info(psi: PAVISTREAMINFOW; lSize: DWORD): HResult; virtual; stdcall; abstract;
  1346.         function    FindSample(lPos: DWORD; lFlags: DWORD): DWORD; virtual; stdcall; abstract;
  1347.         function    ReadFormat(lPos: DWORD; lpFormat: PVOID; lpcbFormat: PDWORD): HResult; virtual; stdcall; abstract;
  1348.         function    SetFormat(lPos: DWORD; lpFormat: PVOID; cbFormat: DWORD): HResult; virtual; stdcall; abstract;
  1349.         function    Read(lStart: DWORD; lSamples: DWORD; lpBuffer: PVOID; cbBuffer: DWORD; plBytes, plSamples: PDWORD): HResult; virtual; stdcall; abstract;
  1350.         function    Write(lStart: DWORD; lSamples: DWORD; lpBuffer: PVOID; cbBuffer: DWORD; dwFlags: DWORD; plSampWritten, plBytesWritten: PDWORD): HResult; virtual; stdcall; abstract;
  1351.         function    Delete(lStart: DWORD; lSamples: DWORD): HResult; virtual; stdcall; abstract;
  1352.         function    ReadData(fcc: DWORD; lp: PVOID; lpcb: PDWORD): HResult; virtual; stdcall; abstract;
  1353.         function    WriteData(fcc: DWORD; lp: PVOID; cb: DWORD): HResult; virtual; stdcall; abstract;
  1354.         function    SetInfo(lpInfo: PAVISTREAMINFOW; cbInfo: DWORD): HResult; virtual; stdcall; abstract;
  1355.     end;
  1356.  
  1357.     PAVIStreaming   = ^IAVIStreaming;
  1358.     IAVIStreaming   = class(IUnknown)
  1359.     public
  1360.         function    _Begin(
  1361.                             lStart,         // start of what we expect to play
  1362.                             lEnd  : DWORD;   // expected end, or -1
  1363.                             lRate : DWORD    // Should this be a float?
  1364.                           ): HResult; virtual; stdcall; abstract;
  1365.         function    _End: HResult; virtual; stdcall; abstract;
  1366.     end;
  1367.  
  1368.     PAVIEditStream  = ^IAVIEditStream;
  1369.     IAVIEditStream  = class(IUnknown)
  1370.     public
  1371.         function    Cut(plStart, plLength: PDWORD; var ppResult: PAVISTREAM): HResult; virtual; stdcall; abstract;
  1372.         function    Copy(plStart, plLength: PDWORD; var ppResult: PAVISTREAM): HResult; virtual; stdcall; abstract;
  1373.         function    Paste(plPos: PDWORD; plLength: PDWORD; pstream: PAVISTREAM; lStart, lEnd: DWORD): HResult; virtual; stdcall; abstract;
  1374.         function    Clone(var ppResult: PAVISTREAM): HResult; virtual; stdcall; abstract;
  1375.         function    SetInfo(lpInfo: PAVISTREAMINFOW; cbInfo: DWORD): HResult; virtual; stdcall; abstract;
  1376.     end;
  1377.  
  1378. {-- AVIFile ------------------------------------------------------------------}
  1379.  
  1380.     PAVIFile        = ^IAVIFile;
  1381.     IAVIFile        = class(IUnknown)
  1382.         function    Info(pfi: PAVIFILEINFOW; lSize: DWORD): HResult; virtual; stdcall; abstract;
  1383.         function    GetStream(var ppStream: PAVISTREAM; fccType: DWORD; lParam: DWORD): HResult; virtual; stdcall; abstract;
  1384.         function    CreateStream(var ppStream: PAVISTREAM; psi: PAVISTREAMINFOW): HResult; virtual; stdcall; abstract;
  1385.         function    WriteData(ckid: DWORD; lpData: PVOID; cbData: DWORD): HResult; virtual; stdcall; abstract;
  1386.         function    ReadData(ckid: DWORD; lpData: PVOID; lpcbData: PDWORD): HResult; virtual; stdcall; abstract;
  1387.         function    EndRecord: HResult; virtual; stdcall; abstract;
  1388.         function    DeleteStream(fccType: DWORD; lParam: DWORD): HResult; virtual; stdcall; abstract;
  1389.     end;
  1390.  
  1391. {-- GetFrame -----------------------------------------------------------------}
  1392.  
  1393.     PGetFrame       = ^IGetFrame;
  1394.     IGetFrame       = class(IUnknown)
  1395.     public
  1396.         function    GetFrame(lPos: DWORD): PVOID; virtual; stdcall; abstract;
  1397.  
  1398.         function    _Begin(lStart, lEnd: DWORD; lRate: DWORD): HResult; virtual; stdcall; abstract;
  1399.         function    _End: HResult; virtual; stdcall; abstract;
  1400.  
  1401.         function    SetFormat(lpbi: PBITMAPINFOHEADER; lpBits: PVOID; x, y, dx, dy: int): HResult; virtual; stdcall; abstract;
  1402.  
  1403.         // STDMETHOD(DrawFrameStart) (THIS) PURE;
  1404.         // STDMETHOD(DrawFrame) (THIS_ DWORD lPos, HDC hdc, int x, int y, int dx, int dy) PURE;
  1405.         // STDMETHOD(DrawFrameEnd) (THIS) PURE;
  1406.     end;
  1407.  
  1408. {-- GUIDs --------------------------------------------------------------------}
  1409.  
  1410. const
  1411.     IID_IAVIFile                : TGUID =
  1412.         (D1: $00020020; D2: $0; D3: $0; D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  1413.     IID_IAVIStream              : TGUID =
  1414.         (D1: $00020021; D2: $0; D3: $0; D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  1415.     IID_IAVIStreaming           : TGUID =
  1416.         (D1: $00020022; D2: $0; D3: $0; D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  1417.     IID_IGetFrame               : TGUID =
  1418.         (D1: $00020023; D2: $0; D3: $0; D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  1419.     IID_IAVIEditStream          : TGUID =
  1420.         (D1: $00020024; D2: $0; D3: $0; D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  1421.  
  1422.     CLSID_AVISimpleUnMarshal    : TGUID =
  1423.         (D1: $00020009; D2: $0; D3: $0; D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  1424.  
  1425.     CLSID_AVIFile               : TGUID =
  1426.         (D1: $00020000; D2: $0; D3: $0; D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  1427.  
  1428.     AVIFILEHANDLER_CANREAD          = $0001;
  1429.     AVIFILEHANDLER_CANWRITE         = $0002;
  1430.     AVIFILEHANDLER_CANACCEPTNONRGB  = $0004;
  1431.  
  1432. {-- Functions ----------------------------------------------------------------}
  1433.  
  1434. procedure   AVIFileInit; stdcall;   // Call this first!
  1435. procedure   AVIFileExit; stdcall;
  1436.  
  1437. function    AVIFileAddRef(pfile: PAVIFILE): UDWORD; stdcall;
  1438. function    AVIFileRelease(pfile: PAVIFILE): UDWORD; stdcall;
  1439.  
  1440. function    AVIFileOpenA(var ppfile: PAVIFILE; szFile: LPCSTR; uMode: UINT; lpHandler: PCLSID): HResult; stdcall;
  1441. function    AVIFileOpenW(var ppfile: PAVIFILE; szFile: LPCWSTR; uMode: UINT; lpHandler: PCLSID): HResult; stdcall;
  1442.  
  1443. function    AVIFileOpen(var ppfile: PAVIFILE; szFile: LPCSTR; uMode: UINT; lpHandler: PCLSID): HResult; stdcall; // AVIFileOpenA
  1444.  
  1445. function    AVIFileInfoW(pfile: PAVIFILE; pfi: PAVIFILEINFOW; lSize: DWORD): HResult; stdcall;
  1446. function    AVIFileInfoA(pfile: PAVIFILE; pfi: PAVIFILEINFOA; lSize: DWORD): HResult; stdcall;
  1447.  
  1448. function    AVIFileInfo(pfile: PAVIFILE; pfi: PAVIFILEINFOA; lSize: DWORD): HResult; stdcall; // AVIFileInfoA
  1449.  
  1450. function    AVIFileGetStream(pfile: PAVIFILE; var ppavi: PAVISTREAM; fccType: DWORD; lParam: DWORD): HResult; stdcall;
  1451.  
  1452. function    AVIFileCreateStreamW(pfile: PAVIFILE; var ppavi: PAVISTREAM; psi: PAVISTREAMINFOW): HResult; stdcall;
  1453. function    AVIFileCreateStreamA(pfile: PAVIFILE; var ppavi: PAVISTREAM; psi: PAVISTREAMINFOA): HResult; stdcall;
  1454.  
  1455. function    AVIFileCreateStream(pfile: PAVIFILE; var ppavi: PAVISTREAM; psi: PAVISTREAMINFOA): HResult; stdcall;    // AVIFileCreateStreamA
  1456.  
  1457. function    AVIFileWriteData(pfile: PAVIFILE; ckid: DWORD; lpData: PVOID; cbData: DWORD): HResult; stdcall;
  1458. function    AVIFileReadData(pfile: PAVIFILE; ckid: DWORD; lpData: PVOID; lpcbData: PDWORD): HResult; stdcall;
  1459. function    AVIFileEndRecord(pfile: PAVIFILE): HResult; stdcall;
  1460.  
  1461. function    AVIStreamAddRef(pavi: PAVISTREAM): UDWORD; stdcall;
  1462. function    AVIStreamRelease(pavi: PAVISTREAM): UDWORD; stdcall;
  1463.  
  1464. function    AVIStreamInfoW (pavi: PAVISTREAM; psi: PAVISTREAMINFOW; lSize: DWORD): HResult; stdcall;
  1465. function    AVIStreamInfoA (pavi: PAVISTREAM; psi: PAVISTREAMINFOA; lSize: DWORD): HResult; stdcall;
  1466.  
  1467. function    AVIStreamInfo(pavi: PAVISTREAM; psi: PAVISTREAMINFOA; lSize: DWORD): HResult; stdcall; // AVIStreamInfoA
  1468.  
  1469. function    AVIStreamFindSample(pavi: PAVISTREAM; lPos: DWORD; lFlags: DWORD): DWORD; stdcall;
  1470. function    AVIStreamReadFormat(pavi: PAVISTREAM; lPos: DWORD; lpFormat: PVOID; lpcbFormat: PDWORD): HResult; stdcall;
  1471. function    AVIStreamSetFormat(pavi: PAVISTREAM; lPos: DWORD; lpFormat: PVOID; cbFormat: DWORD): HResult; stdcall;
  1472. function    AVIStreamReadData(pavi: PAVISTREAM; fcc: DWORD; lp: PVOID; lpcb: PDWORD): HResult; stdcall;
  1473. function    AVIStreamWriteData(pavi: PAVISTREAM; fcc: DWORD; lp: PVOID; cb: DWORD): HResult; stdcall;
  1474.  
  1475. function    AVIStreamRead(
  1476.     pavi            : PAVISTREAM;
  1477.     lStart          : DWORD;
  1478.     lSamples        : DWORD;
  1479.     lpBuffer        : PVOID;
  1480.     cbBuffer        : DWORD;
  1481.     plBytes         : PDWORD;
  1482.     plSamples       : PDWORD
  1483.     ): HResult; stdcall;
  1484.  
  1485. const
  1486.     AVISTREAMREAD_CONVENIENT    = -1;
  1487.  
  1488. function    AVIStreamWrite(
  1489.     pavi            : PAVISTREAM;
  1490.     lStart,
  1491.     lSamples        : DWORD;
  1492.     lpBuffer        : PVOID;
  1493.     cbBuffer        : DWORD;
  1494.     dwFlags         : DWORD;
  1495.     plSampWritten   : PDWORD;
  1496.     plBytesWritten  : PDWORD
  1497.     ): HResult; stdcall;
  1498.  
  1499. // Right now, these just use AVIStreamInfo() to get information, then
  1500. // return some of it.  Can they be more efficient?
  1501.  
  1502. function    AVIStreamStart(pavi: PAVISTREAM): DWORD; stdcall;
  1503. function    AVIStreamLength(pavi: PAVISTREAM): DWORD; stdcall;
  1504. function    AVIStreamTimeToSample(pavi: PAVISTREAM; lTime: DWORD): DWORD; stdcall;
  1505. function    AVIStreamSampleToTime(pavi: PAVISTREAM; lSample: DWORD): DWORD; stdcall;
  1506.  
  1507. function    AVIStreamBeginStreaming(pavi: PAVISTREAM; lStart, lEnd: DWORD; lRate: DWORD): HResult; stdcall;
  1508. function    AVIStreamEndStreaming(pavi: PAVISTREAM): HResult; stdcall;
  1509.  
  1510. {-- Helper functions for using IGetFrame -------------------------------------}
  1511.  
  1512. function    AVIStreamGetFrameOpen(pavi: PAVISTREAM; lpbiWanted: PBITMAPINFOHEADER): PGETFRAME; stdcall;
  1513. function    AVIStreamGetFrame(pg: PGETFRAME; lPos: DWORD): PVOID; stdcall;
  1514. function    AVIStreamGetFrameClose(pg: PGETFRAME): HResult; stdcall;
  1515.  
  1516. // !!! We need some way to place an advise on a stream....
  1517. // STDAPI AVIStreamHasChanged   (PAVISTREAM pavi);
  1518.  
  1519. {-- Shortcut function --------------------------------------------------------}
  1520.  
  1521. function    AVIStreamOpenFromFileA(var ppavi: PAVISTREAM; szFile: LPCSTR; fccType: DWORD;
  1522.                                    lParam: DWORD; mode: UINT; pclsidHandler: PCLSID): HResult; stdcall;
  1523. function    AVIStreamOpenFromFileW(var ppavi: PAVISTREAM; szFile: LPCWSTR; fccType: DWORD;
  1524.                                    lParam: DWORD; mode: UINT; pclsidHandler: PCLSID): HResult; stdcall;
  1525.  
  1526. function    AVIStreamOpenFromFile(var ppavi: PAVISTREAM; szFile: LPCSTR; fccType: DWORD;
  1527.                                   lParam: DWORD; mode: UINT; pclsidHandler: PCLSID): HResult; stdcall; // AVIStreamOpenFromFileA
  1528.  
  1529. {-- Use to create disembodied streams ----------------------------------------}
  1530.  
  1531. function    AVIStreamCreate(var ppavi: PAVISTREAM; lParam1, lParam2: DWORD;
  1532.                             pclsidHandler: PCLSID): HResult; stdcall;
  1533.  
  1534. // PHANDLER    AVIAPI AVIGetHandler         (PAVISTREAM pavi, PAVISTREAMHANDLER psh);
  1535. // PAVISTREAM  AVIAPI AVIGetStream          (PHANDLER p);
  1536.  
  1537. {-- Flags for AVIStreamFindSample --------------------------------------------}
  1538.  
  1539. const
  1540.     FIND_DIR                        = $0000000F;    // direction
  1541.     FIND_NEXT                       = $00000001;    // go forward
  1542.     FIND_PREV                       = $00000004;    // go backward
  1543.     FIND_FROM_START                 = $00000008;    // start at the logical beginning
  1544.  
  1545.     FIND_TYPE                       = $000000F0;    // type mask
  1546.     FIND_KEY                        = $00000010;    // find key frame.
  1547.     FIND_ANY                        = $00000020;    // find any (non-empty) sample
  1548.     FIND_FORMAT                     = $00000040;    // find format change
  1549.  
  1550.     FIND_RET                        = $0000F000;    // return mask
  1551.     FIND_POS                        = $00000000;    // return logical position
  1552.     FIND_LENGTH                     = $00001000;    // return logical size
  1553.     FIND_OFFSET                     = $00002000;    // return physical position
  1554.     FIND_SIZE                       = $00003000;    // return physical size
  1555.     FIND_INDEX                      = $00004000;    // return physical index position
  1556.  
  1557. {-- Stuff to support backward compat. ----------------------------------------}
  1558.  
  1559. function    AVIStreamFindKeyFrame(pavi: PAVISTREAM; lPos: DWORD; lFlags: DWORD): DWORD; stdcall; // AVIStreamFindSample
  1560.  
  1561. // Non-portable: this is alias for method name
  1562. // FindKeyFrame FindSample
  1563.  
  1564. function    AVIStreamClose(pavi: PAVISTREAM): UDWORD; stdcall; // AVIStreamRelease
  1565. function    AVIFileClose(pfile: PAVIFILE): UDWORD; stdcall; // AVIFileRelease
  1566. procedure   AVIStreamInit; stdcall; // AVIFileInit
  1567. procedure   AVIStreamExit; stdcall; // AVIFileExit
  1568.  
  1569. const
  1570.     SEARCH_NEAREST                  = FIND_PREV;
  1571.     SEARCH_BACKWARD                 = FIND_PREV;
  1572.     SEARCH_FORWARD                  = FIND_NEXT;
  1573.     SEARCH_KEY                      = FIND_KEY;
  1574.     SEARCH_ANY                      = FIND_ANY;
  1575.  
  1576. {-- Helper macros ------------------------------------------------------------}
  1577.  
  1578. function    AVIStreamSampleToSample(pavi1, pavi2: PAVISTREAM; l: DWORD): DWORD;
  1579. function    AVIStreamNextSample(pavi: PAVISTREAM; l: DWORD): DWORD;
  1580. function    AVIStreamPrevSample(pavi: PAVISTREAM; l: DWORD): DWORD;
  1581. function    AVIStreamNearestSample(pavi: PAVISTREAM; l: DWORD): DWORD;
  1582. function    AVIStreamNextKeyFrame(pavi: PAVISTREAM; l: DWORD): DWORD;
  1583. function    AVIStreamPrevKeyFrame(pavi: PAVISTREAM; l: DWORD): DWORD;
  1584. function    AVIStreamNearestKeyFrame(pavi: PAVISTREAM; l: DWORD): DWORD;
  1585. function    AVIStreamIsKeyFrame(pavi: PAVISTREAM; l: DWORD): BOOL;
  1586. function    AVIStreamPrevSampleTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  1587. function    AVIStreamNextSampleTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  1588. function    AVIStreamNearestSampleTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  1589. function    AVIStreamNextKeyFrameTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  1590. function    AVIStreamPrevKeyFrameTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  1591. function    AVIStreamNearestKeyFrameTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  1592. function    AVIStreamStartTime(pavi: PAVISTREAM): DWORD;
  1593. function    AVIStreamLengthTime(pavi: PAVISTREAM): DWORD;
  1594. function    AVIStreamEnd(pavi: PAVISTREAM): DWORD;
  1595. function    AVIStreamEndTime(pavi: PAVISTREAM): DWORD;
  1596. function    AVIStreamSampleSize(pavi: PAVISTREAM; lPos: DWORD; plSize: PDWORD): DWORD;
  1597. function    AVIStreamFormatSize(pavi: PAVISTREAM; lPos: DWORD; plSize: PDWORD): HResult;
  1598. function    AVIStreamDataSize(pavi: PAVISTREAM; fcc: DWORD; plSize: PDWORD): HResult;
  1599.  
  1600. {== AVISave routines and structures ==========================================}
  1601.  
  1602. const
  1603.     comptypeDIB                     = $20424944; // mmioFOURCC('D', 'I', 'B', ' ')
  1604.  
  1605. function    AVIMakeCompressedStream(
  1606.     var ppsCompressed   : PAVISTREAM;
  1607.     ppsSource           : PAVISTREAM;
  1608.     lpOptions           : PAVICOMPRESSOPTIONS;
  1609.     pclsidHandler       : PCLSID
  1610.     ): HResult; stdcall;
  1611.  
  1612. // Non-portable: uses variable number of params
  1613. // EXTERN_C HRESULT CDECL AVISaveA (LPCSTR               szFile,
  1614. //      CLSID FAR *pclsidHandler,
  1615. //      AVISAVECALLBACK     lpfnCallback,
  1616. //      int                 nStreams,
  1617. //      PAVISTREAM      pfile,
  1618. //      LPAVICOMPRESSOPTIONS lpOptions,
  1619. //      ...);
  1620.  
  1621. function    AVISaveVA(
  1622.     szFile          : LPCSTR;
  1623.     pclsidHandler   : PCLSID;
  1624.     lpfnCallback    : TAVISAVECALLBACK;
  1625.     nStreams        : int;
  1626.     var ppavi       : PAVISTREAM;
  1627.     var plpOptions  : PAVICOMPRESSOPTIONS
  1628.     ): HResult; stdcall;
  1629.  
  1630. // Non-portable: uses variable number of params
  1631. // EXTERN_C HRESULT CDECL AVISaveW (LPCWSTR               szFile,
  1632. //      CLSID FAR *pclsidHandler,
  1633. //      AVISAVECALLBACK     lpfnCallback,
  1634. //      int                 nStreams,
  1635. //      PAVISTREAM      pfile,
  1636. //      LPAVICOMPRESSOPTIONS lpOptions,
  1637. //      ...);
  1638.  
  1639. function    AVISaveVW(
  1640.     szFile          : LPCWSTR;
  1641.     pclsidHandler   : PCLSID;
  1642.     lpfnCallback    : TAVISAVECALLBACK;
  1643.     nStreams        : int;
  1644.     var ppavi       : PAVISTREAM;
  1645.     var plpOptions  : PAVICOMPRESSOPTIONS
  1646.     ): HResult; stdcall;
  1647.  
  1648. // #define AVISave      AVISaveA
  1649.  
  1650. function    AVISaveV(
  1651.     szFile          : LPCSTR;
  1652.     pclsidHandler   : PCLSID;
  1653.     lpfnCallback    : TAVISAVECALLBACK;
  1654.     nStreams        : int;
  1655.     var ppavi       : PAVISTREAM;
  1656.     var plpOptions  : PAVICOMPRESSOPTIONS
  1657.     ): HResult; stdcall; // AVISaveVA
  1658.  
  1659. function    AVISaveOptions(
  1660.     hwnd            : HWND;
  1661.     uiFlags         : UINT;
  1662.     nStreams        : int;
  1663.     var ppavi       : PAVISTREAM;
  1664.     var plpOptions  : PAVICOMPRESSOPTIONS
  1665.     ): BOOL; stdcall;
  1666.  
  1667. function    AVISaveOptionsFree(nStreams: int; var plpOptions: PAVICOMPRESSOPTIONS): HResult; stdcall;
  1668.  
  1669. {-- FLAGS FOR uiFlags --------------------------------------------------------}
  1670.  
  1671. // Same as the flags for ICCompressorChoose (see compman.h)
  1672. // These determine what the compression options dialog for video streams
  1673. // will look like.
  1674.  
  1675. function    AVIBuildFilterW(lpszFilter: LPWSTR; cbFilter: DWORD; fSaving: BOOL): HResult; stdcall;
  1676. function    AVIBuildFilterA(lpszFilter: LPSTR; cbFilter: DWORD; fSaving: BOOL): HResult; stdcall;
  1677.  
  1678. function    AVIBuildFilter(lpszFilter: LPSTR; cbFilter: DWORD; fSaving: BOOL): HResult; stdcall; // AVIBuildFilterA
  1679.  
  1680. function    AVIMakeFileFromStreams(var ppfile: PAVIFILE; nStreams: int; var papStreams: PAVISTREAM): HResult; stdcall;
  1681.  
  1682. function    AVIMakeStreamFromClipboard(cfFormat: UINT; hGlobal: THANDLE; var ppstream: PAVISTREAM): HResult; stdcall;
  1683.  
  1684. {-- Clipboard routines -------------------------------------------------------}
  1685.  
  1686. function    AVIPutFileOnClipboard(pf: PAVIFILE): HResult; stdcall;
  1687. function    AVIGetFromClipboard(var lppf: PAVIFILE): HResult; stdcall;
  1688. function    AVIClearClipboard: HResult; stdcall;
  1689.  
  1690. {-- Editing routines ---------------------------------------------------------}
  1691.  
  1692. function    CreateEditableStream(var ppsEditable: PAVISTREAM; psSource: PAVISTREAM): HResult; stdcall;
  1693.  
  1694. function    EditStreamCut(pavi: PAVISTREAM; plStart, plLength: PDWORD; var ppResult: PAVISTREAM): HResult; stdcall;
  1695.  
  1696. function    EditStreamCopy(pavi: PAVISTREAM; plStart, plLength: PDWORD; var ppResult: PAVISTREAM): HResult; stdcall;
  1697.  
  1698. function    EditStreamPaste(pavi: PAVISTREAM; plPos, plLength: PDWORD; pstream: PAVISTREAM; lStart, lEnd: DWORD): HResult; stdcall;
  1699.  
  1700. function    EditStreamClone(pavi: PAVISTREAM; var ppResult: PAVISTREAM): HResult; stdcall;
  1701.  
  1702. function    EditStreamSetNameA(pavi: PAVISTREAM; lpszName: LPCSTR): HResult; stdcall;
  1703. function    EditStreamSetNameW(pavi: PAVISTREAM; lpszName: LPCWSTR): HResult; stdcall;
  1704. function    EditStreamSetInfoW(pavi: PAVISTREAM; lpInfo: PAVISTREAMINFOW; cbInfo: DWORD): HResult; stdcall;
  1705. function    EditStreamSetInfoA(pavi: PAVISTREAM; lpInfo: PAVISTREAMINFOA; cbInfo: DWORD): HResult; stdcall;
  1706.  
  1707. function    EditStreamSetInfo(pavi: PAVISTREAM; lpInfo: PAVISTREAMINFOA; cbInfo: DWORD): HResult; stdcall; // EditStreamSetInfoA
  1708. function    EditStreamSetName(pavi: PAVISTREAM; lpszName: LPCSTR): HResult; stdcall; // EditStreamSetNameA
  1709.  
  1710. {-- Error handling -----------------------------------------------------------}
  1711.  
  1712. const
  1713.     AVIERR_OK                       = 0;
  1714.  
  1715. // !!! Questions to be answered:
  1716. // How can you get a string form of these errors?
  1717. // Which of these errors should be replaced by errors in SCODE.H?
  1718.  
  1719. const
  1720.     AVIERR_UNSUPPORTED              = $80044065; // MAKE_AVIERR(101)
  1721.     AVIERR_BADFORMAT                = $80044066; // MAKE_AVIERR(102)
  1722.     AVIERR_MEMORY                   = $80044067; // MAKE_AVIERR(103)
  1723.     AVIERR_INTERNAL                 = $80044068; // MAKE_AVIERR(104)
  1724.     AVIERR_BADFLAGS                 = $80044069; // MAKE_AVIERR(105)
  1725.     AVIERR_BADPARAM                 = $8004406A; // MAKE_AVIERR(106)
  1726.     AVIERR_BADSIZE                  = $8004406B; // MAKE_AVIERR(107)
  1727.     AVIERR_BADHANDLE                = $8004406C; // MAKE_AVIERR(108)
  1728.     AVIERR_FILEREAD                 = $8004406D; // MAKE_AVIERR(109)
  1729.     AVIERR_FILEWRITE                = $8004406E; // MAKE_AVIERR(110)
  1730.     AVIERR_FILEOPEN                 = $8004406F; // MAKE_AVIERR(111)
  1731.     AVIERR_COMPRESSOR               = $80044070; // MAKE_AVIERR(112)
  1732.     AVIERR_NOCOMPRESSOR             = $80044071; // MAKE_AVIERR(113)
  1733.     AVIERR_READONLY                 = $80044072; // MAKE_AVIERR(114)
  1734.     AVIERR_NODATA                   = $80044073; // MAKE_AVIERR(115)
  1735.     AVIERR_BUFFERTOOSMALL           = $80044074; // MAKE_AVIERR(116)
  1736.     AVIERR_CANTCOMPRESS             = $80044075; // MAKE_AVIERR(117)
  1737.     AVIERR_USERABORT                = $800440C6; // MAKE_AVIERR(198)
  1738.     AVIERR_ERROR                    = $800440C7; // MAKE_AVIERR(199)
  1739.  
  1740. {== MCIWnd - Window class for MCI objects ====================================}
  1741.  
  1742. //
  1743. //  MCIWnd
  1744. //
  1745. //    MCIWnd window class header file.
  1746. //
  1747. //    the MCIWnd window class is a window class for controling MCI devices
  1748. //    MCI devices include, wave files, midi files, AVI Video, cd audio,
  1749. //    vcr, video disc, and others..
  1750. //
  1751. //    to learn more about MCI and mci command sets see the
  1752. //    "Microsoft Multimedia Programmers's guide" in the Win31 SDK
  1753. //
  1754. //    the easiest use of the MCIWnd class is like so:
  1755. //
  1756. //          hwnd = MCIWndCreate(hwndParent, hInstance, 0, "chimes.wav");
  1757. //          ...
  1758. //          MCIWndPlay(hwnd);
  1759. //          MCIWndStop(hwnd);
  1760. //          MCIWndPause(hwnd);
  1761. //          ....
  1762. //          MCIWndDestroy(hwnd);
  1763. //
  1764. //    this will create a window with a play/pause, stop and a playbar
  1765. //    and start the wave file playing.
  1766. //
  1767. //    mciwnd.h defines macros for all the most common MCI commands, but
  1768. //    any string command can be used if needed.
  1769. //
  1770. //    Note: unlike the mciSendString() API, no alias or file name needs
  1771. //    to be specifed, since the device to use is implied by the window handle.
  1772. //
  1773. //          MCIWndSendString(hwnd, "setaudio stream to 2");
  1774. //
  1775. //    (C) Copyright Microsoft Corp. 1991-1995.  All rights reserved.
  1776. //
  1777. // WIN32:
  1778. //
  1779. //    MCIWnd supports both ansi and unicode interfaces. For any message that
  1780. //    takes or returns a text string, two versions of the message are defined,
  1781. //    appended with A or W for Ansi or Wide Char. The message or api itself
  1782. //    is defined to be one or other of these depending on whether you have
  1783. //    UNICODE defined in your application.
  1784. //    Thus for the api MCIWndCreate, there are in fact two apis,
  1785. //    MCIWndCreateA and MCIWndCreateW. If you call MCIWndCreate, this will be
  1786. //    re-routed to MCIWndCreateA unless UNICODE is defined when building your
  1787. //    application. In any one application, you can mix calls to the
  1788. //    Ansi and Unicode entrypoints.
  1789. //
  1790. //    If you use SendMessage instead of the macros below such as MCIWndOpen(),
  1791. //    you will see that the messages have changed for WIN32, to support Ansi
  1792. //    and Unicode entrypoints. In particular, MCI_OPEN has been replaced by
  1793. //    MCWNDM_OPENA, or MCIWNDM_OPENW (MCIWNDM_OPEN is defined to be one or
  1794. //    other of these).
  1795. //
  1796. //    Also, note that the WIN32 implementation of MCIWnd uses UNICODE
  1797. //    so all apis and messages supporting ANSI strings do so by mapping them
  1798. //    UNICODE strings and then calling the corresponding UNICODE entrypoint.
  1799. //
  1800.  
  1801. function    MCIWndSM(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): DWORD;
  1802.  
  1803. const                               
  1804.     MCIWND_WINDOW_CLASS             = 'MCIWndClass' ;
  1805.  
  1806. function    MCIWndCreateA(hwndParent: HWND; hInstance: HINST; dwStyle: DWORd; szFile: LPCSTR): HWND; cdecl;
  1807. function    MCIWndCreateW(hwndParent: HWND; hInstance: HINST; dwStyle: DWORd; szFile: LPCWSTR): HWND; cdecl;
  1808.  
  1809. function    MCIWndCreate(hwndParent: HWND; hInstance: HINST; dwStyle: DWORd; szFile: LPCSTR): HWND; cdecl; // MCIWndCreateA
  1810.  
  1811. function    MCIWndRegisterClass: BOOL; cdecl;
  1812.  
  1813. {-- Flags for the MCIWndOpen command -----------------------------------------}
  1814.  
  1815. const
  1816.     MCIWNDOPENF_NEW                 = $0001;    // open a new file
  1817.  
  1818. {-- Window styles ------------------------------------------------------------}
  1819.  
  1820.     MCIWNDF_NOAUTOSIZEWINDOW        = $0001;    // when movie size changes
  1821.     MCIWNDF_NOPLAYBAR               = $0002;    // no toolbar
  1822.     MCIWNDF_NOAUTOSIZEMOVIE         = $0004;    // when window size changes
  1823.     MCIWNDF_NOMENU                  = $0008;    // no popup menu from RBUTTONDOWN
  1824.     MCIWNDF_SHOWNAME                = $0010;    // show name in caption
  1825.     MCIWNDF_SHOWPOS                 = $0020;    // show position in caption
  1826.     MCIWNDF_SHOWMODE                = $0040;    // show mode in caption
  1827.     MCIWNDF_SHOWALL                 = $0070;    // show all
  1828.  
  1829.     MCIWNDF_NOTIFYMODE              = $0100;    // tell parent of mode change
  1830.     MCIWNDF_NOTIFYPOS               = $0200;    // tell parent of pos change
  1831.     MCIWNDF_NOTIFYSIZE              = $0400;    // tell parent of size change
  1832.     MCIWNDF_NOTIFYERROR             = $1000;    // tell parent of an error
  1833.     MCIWNDF_NOTIFYALL               = $1F00;    // tell all
  1834.  
  1835.     MCIWNDF_NOTIFYANSI              = $0080;
  1836.  
  1837. // The MEDIA notification includes a text string.
  1838. // To receive notifications in ANSI instead of unicode set the
  1839. // MCIWNDF_NOTIFYANSI style bit. The macro below includes this bit
  1840. // by default unless you define UNICODE in your application.
  1841.  
  1842.     MCIWNDF_NOTIFYMEDIAA            = $0880;    // tell parent of media change
  1843.     MCIWNDF_NOTIFYMEDIAW            = $0800;    // tell parent of media change
  1844.  
  1845.     MCIWNDF_NOTIFYMEDIA             = MCIWNDF_NOTIFYMEDIAA;
  1846.  
  1847.     MCIWNDF_RECORD                  = $2000;    // Give a record button
  1848.     MCIWNDF_NOERRORDLG              = $4000;    // Show Error Dlgs for MCI cmds?
  1849.     MCIWNDF_NOOPEN                  = $8000;    // Don't allow user to open things
  1850.  
  1851. {-- Can macros ---------------------------------------------------------------}
  1852.  
  1853. function    MCIWndCanPlay(hwnd: HWND): BOOL;
  1854. function    MCIWndCanRecord(hwnd: HWND): BOOL;
  1855. function    MCIWndCanSave(hwnd: HWND): BOOL;
  1856. function    MCIWndCanWindow(hwnd: HWND): BOOL;
  1857. function    MCIWndCanEject(hwnd: HWND): BOOL;
  1858. function    MCIWndCanConfig(hwnd: HWND): BOOL;
  1859. function    MCIWndPaletteKick(hwnd: HWND): BOOL;
  1860.  
  1861. function    MCIWndSave(hwnd: HWND; szFile: LPCSTR): DWORD;
  1862. function    MCIWndSaveDialog(hwnd: HWND): DWORD;
  1863.  
  1864. // If you dont give a device it will use the current device....
  1865.  
  1866. function    MCIWndNew(hwnd: HWND; lp: PVOID): DWORD;
  1867. function    MCIWndRecord(hwnd: HWND): DWORD;
  1868. function    MCIWndOpen(hwnd: HWND; sz: LPCSTR; f: BOOL): DWORD;
  1869. function    MCIWndOpenDialog(hwnd: HWND): DWORD;
  1870. function    MCIWndClose(hwnd: HWND): DWORD;
  1871. function    MCIWndPlay(hwnd: HWND): DWORD;
  1872. function    MCIWndStop(hwnd: HWND): DWORD;
  1873. function    MCIWndPause(hwnd: HWND): DWORD;
  1874. function    MCIWndResume(hwnd: HWND): DWORD;
  1875. function    MCIWndSeek(hwnd: HWND; lPos: DWORD): DWORD;
  1876. function    MCIWndEject(hwnd: HWND): DWORD;
  1877.  
  1878. function    MCIWndHome(hwnd: HWND): DWORD;
  1879. function    MCIWndEnd(hwnd: HWND): DWORD;
  1880.  
  1881. function    MCIWndGetSource(hwnd: HWND; prc: PRECT): DWORD;
  1882. function    MCIWndPutSource(hwnd: HWND; prc: PRECT): DWORD;
  1883.  
  1884. function    MCIWndGetDest(hwnd: HWND; prc: PRECT): DWORD;
  1885. function    MCIWndPutDest(hwnd: HWND; prc: PRECT): DWORD;
  1886.  
  1887. function    MCIWndPlayReverse(hwnd: HWND): DWORD;
  1888. function    MCIWndPlayFrom(hwnd: HWND; lPos: DWORD): DWORD;
  1889. function    MCIWndPlayTo(hwnd: HWND; lPos: DWORD): DWORD;
  1890. function    MCIWndPlayFromTo(hwnd: HWND; lStart, lEnd: DWORD): DWORD;
  1891.  
  1892. function    MCIWndGetDeviceID(hwnd: HWND): UINT;
  1893. function    MCIWndGetAlias(hwnd: HWND): UINT;
  1894. function    MCIWndGetMode(hwnd: HWND; lp: LPSTR; len: UINT): DWORD;
  1895. function    MCIWndGetPosition(hwnd: HWND): DWORD;
  1896. function    MCIWndGetPositionString(hwnd: HWND; lp: LPSTR; len: UINT): DWORD;
  1897. function    MCIWndGetStart(hwnd: HWND): DWORD;
  1898. function    MCIWndGetLength(hwnd: HWND): DWORD;
  1899. function    MCIWndGetEnd(hwnd: HWND): DWORD;
  1900.  
  1901. function    MCIWndStep(hwnd: HWND; n: DWORD): DWORD;
  1902.  
  1903. procedure   MCIWndDestroy(hwnd: HWND);
  1904. procedure   MCIWndSetZoom(hwnd: HWND; iZoom: UINT);
  1905. function    MCIWndGetZoom(hwnd: HWND): UINT;
  1906. function    MCIWndSetVolume(hwnd: HWND; iVol: UINT): DWORD;
  1907. function    MCIWndGetVolume(hwnd: HWND): DWORD;
  1908. function    MCIWndSetSpeed(hwnd: HWND; iSpeed: UINT): DWORD;
  1909. function    MCIWndGetSpeed(hwnd: HWND): DWORD;
  1910. function    MCIWndSetTimeFormat(hwnd: HWND; lp: LPCSTR): DWORD;
  1911. function    MCIWndGetTimeFormat(hwnd: HWND; lp: LPSTR; len: UINT): DWORD;
  1912. procedure   MCIWndValidateMedia(hwnd: HWND);
  1913.  
  1914. procedure   MCIWndSetRepeat(hwnd: HWND; f: BOOL);
  1915. function    MCIWndGetRepeat(hwnd: HWND): BOOL;
  1916.  
  1917. function    MCIWndUseFrames(hwnd: HWND): DWORD;
  1918. function    MCIWndUseTime(hwnd: HWND): DWORD;
  1919.  
  1920. procedure   MCIWndSetActiveTimer(hwnd: HWND; active: UINT);
  1921. procedure   MCIWndSetInactiveTimer(hwnd: HWND; inactive: UINT);
  1922. procedure   MCIWndSetTimers(hwnd: HWND; active, inactive: UINT);
  1923. function    MCIWndGetActiveTimer(hwnd: HWND): UINT;
  1924. function    MCIWndGetInactiveTimer(hwnd: HWND): UINT;
  1925.  
  1926. function    MCIWndRealize(hwnd: HWND; fBkgnd: BOOL): DWORD;
  1927.  
  1928. function    MCIWndSendString(hwnd: HWND; sz: LPCSTR): DWORD;
  1929. function    MCIWndReturnString(hwnd: HWND; lp: LPSTR; len: UINT): DWORD;
  1930. function    MCIWndGetError(hwnd: HWND; lp: LPSTR; len: UINT): DWORD;
  1931.  
  1932. // #define MCIWndActivate(hwnd, f)     (void)MCIWndSM(hwnd, WM_ACTIVATE, (WPARAM)(BOOL)(f), 0)
  1933.  
  1934. function    MCIWndGetPalette(hwnd: HWND): HPALETTE;
  1935. function    MCIWndSetPalette(hwnd: HWND; hpal: HPALETTE): DWORD;
  1936.  
  1937. function    MCIWndGetFileName(hwnd: HWND; lp: LPSTR; len: UINT): DWORD;
  1938. function    MCIWndGetDevice(hwnd: HWND; lp: LPSTR; len: UINT): DWORD;
  1939.  
  1940. function    MCIWndGetStyles(hwnd: HWND): UINT;
  1941. function    MCIWndChangeStyles(hwnd: HWND; mask: UINT; value: DWORD): DWORD;
  1942.  
  1943. type
  1944.     PUnknown    = ^IUnknown;
  1945.  
  1946. function    MCIWndOpenInterface(hwnd: HWND; pUnk: PUnknown): DWORD;
  1947.  
  1948. function    MCIWndSetOwner(hwnd: HWND; hwndP: HWND): DWORD;
  1949.  
  1950. {-- Messages an app will send to MCIWND --------------------------------------}
  1951.  
  1952. // all the text-related messages are defined out of order above (they need
  1953. // to be defined before the MCIWndOpen() macros
  1954.  
  1955. const
  1956.     MCIWNDM_GETDEVICEID             = WM_USER + 100;
  1957.     MCIWNDM_GETSTART                = WM_USER + 103;
  1958.     MCIWNDM_GETLENGTH               = WM_USER + 104;
  1959.     MCIWNDM_GETEND                  = WM_USER + 105;
  1960.     MCIWNDM_EJECT                   = WM_USER + 107;
  1961.     MCIWNDM_SETZOOM                 = WM_USER + 108;
  1962.     MCIWNDM_GETZOOM                 = WM_USER + 109;
  1963.     MCIWNDM_SETVOLUME               = WM_USER + 110;
  1964.     MCIWNDM_GETVOLUME               = WM_USER + 111;
  1965.     MCIWNDM_SETSPEED                = WM_USER + 112;
  1966.     MCIWNDM_GETSPEED                = WM_USER + 113;
  1967.     MCIWNDM_SETREPEAT               = WM_USER + 114;
  1968.     MCIWNDM_GETREPEAT               = WM_USER + 115;
  1969.     MCIWNDM_REALIZE                 = WM_USER + 118;
  1970.     MCIWNDM_VALIDATEMEDIA           = WM_USER + 121;
  1971.     MCIWNDM_PLAYFROM                = WM_USER + 122;
  1972.     MCIWNDM_PLAYTO                  = WM_USER + 123;
  1973.     MCIWNDM_GETPALETTE              = WM_USER + 126;
  1974.     MCIWNDM_SETPALETTE              = WM_USER + 127;
  1975.     MCIWNDM_SETTIMERS               = WM_USER + 129;
  1976.     MCIWNDM_SETACTIVETIMER          = WM_USER + 130;
  1977.     MCIWNDM_SETINACTIVETIMER        = WM_USER + 131;
  1978.     MCIWNDM_GETACTIVETIMER          = WM_USER + 132;
  1979.     MCIWNDM_GETINACTIVETIMER        = WM_USER + 133;
  1980.     MCIWNDM_CHANGESTYLES            = WM_USER + 135;
  1981.     MCIWNDM_GETSTYLES               = WM_USER + 136;
  1982.     MCIWNDM_GETALIAS                = WM_USER + 137;
  1983.     MCIWNDM_PLAYREVERSE             = WM_USER + 139;
  1984.     MCIWNDM_GET_SOURCE              = WM_USER + 140;
  1985.     MCIWNDM_PUT_SOURCE              = WM_USER + 141;
  1986.     MCIWNDM_GET_DEST                = WM_USER + 142;
  1987.     MCIWNDM_PUT_DEST                = WM_USER + 143;
  1988.     MCIWNDM_CAN_PLAY                = WM_USER + 144;
  1989.     MCIWNDM_CAN_WINDOW              = WM_USER + 145;
  1990.     MCIWNDM_CAN_RECORD              = WM_USER + 146;
  1991.     MCIWNDM_CAN_SAVE                = WM_USER + 147;
  1992.     MCIWNDM_CAN_EJECT               = WM_USER + 148;
  1993.     MCIWNDM_CAN_CONFIG              = WM_USER + 149;
  1994.     MCIWNDM_PALETTEKICK             = WM_USER + 150;
  1995.     MCIWNDM_OPENINTERFACE           = WM_USER + 151;
  1996.     MCIWNDM_SETOWNER                = WM_USER + 152;
  1997.  
  1998. {-- Define both A and W messages ---------------------------------------------}
  1999.  
  2000.     MCIWNDM_SENDSTRINGA             = WM_USER + 101;
  2001.     MCIWNDM_GETPOSITIONA            = WM_USER + 102;
  2002.     MCIWNDM_GETMODEA                = WM_USER + 106;
  2003.     MCIWNDM_SETTIMEFORMATA          = WM_USER + 119;
  2004.     MCIWNDM_GETTIMEFORMATA          = WM_USER + 120;
  2005.     MCIWNDM_GETFILENAMEA            = WM_USER + 124;
  2006.     MCIWNDM_GETDEVICEA              = WM_USER + 125;
  2007.     MCIWNDM_GETERRORA               = WM_USER + 128;
  2008.     MCIWNDM_NEWA                    = WM_USER + 134;
  2009.     MCIWNDM_RETURNSTRINGA           = WM_USER + 138;
  2010.     MCIWNDM_OPENA                   = WM_USER + 153;
  2011.  
  2012.     MCIWNDM_SENDSTRINGW             = WM_USER + 201;
  2013.     MCIWNDM_GETPOSITIONW            = WM_USER + 202;
  2014.     MCIWNDM_GETMODEW                = WM_USER + 206;
  2015.     MCIWNDM_SETTIMEFORMATW          = WM_USER + 219;
  2016.     MCIWNDM_GETTIMEFORMATW          = WM_USER + 220;
  2017.     MCIWNDM_GETFILENAMEW            = WM_USER + 224;
  2018.     MCIWNDM_GETDEVICEW              = WM_USER + 225;
  2019.     MCIWNDM_GETERRORW               = WM_USER + 228;
  2020.     MCIWNDM_NEWW                    = WM_USER + 234;
  2021.     MCIWNDM_RETURNSTRINGW           = WM_USER + 238;
  2022.     MCIWNDM_OPENW                   = WM_USER + 252;
  2023.  
  2024. {-- Map defaults to A --------------------------------------------------------}
  2025.  
  2026.     MCIWNDM_SENDSTRING              = MCIWNDM_SENDSTRINGA;
  2027.     MCIWNDM_GETPOSITION             = MCIWNDM_GETPOSITIONA;
  2028.     MCIWNDM_GETMODE                 = MCIWNDM_GETMODEA;
  2029.     MCIWNDM_SETTIMEFORMAT           = MCIWNDM_SETTIMEFORMATA;
  2030.     MCIWNDM_GETTIMEFORMAT           = MCIWNDM_GETTIMEFORMATA;
  2031.     MCIWNDM_GETFILENAME             = MCIWNDM_GETFILENAMEA;
  2032.     MCIWNDM_GETDEVICE               = MCIWNDM_GETDEVICEA;
  2033.     MCIWNDM_GETERROR                = MCIWNDM_GETERRORA;
  2034.     MCIWNDM_NEW                     = MCIWNDM_NEWA;
  2035.     MCIWNDM_RETURNSTRING            = MCIWNDM_RETURNSTRINGA;
  2036.     MCIWNDM_OPEN                    = MCIWNDM_OPENA;
  2037.  
  2038. // note that the source text for MCIWND will thus contain
  2039. // support for eg MCIWNDM_SENDSTRING (both the 16-bit entrypoint and
  2040. // in win32 mapped to MCIWNDM_SENDSTRINGW), and MCIWNDM_SENDSTRINGA (the
  2041. // win32 ansi thunk).
  2042.  
  2043. {-- Messages MCIWND will send to an app --------------------------------------}
  2044.  
  2045. const
  2046.     MCIWNDM_NOTIFYMODE              = WM_USER + 200;    // wp = hwnd, lp = mode
  2047.     MCIWNDM_NOTIFYPOS               = WM_USER + 201;    // wp = hwnd, lp = pos
  2048.     MCIWNDM_NOTIFYSIZE              = WM_USER + 202;    // wp = hwnd
  2049.     MCIWNDM_NOTIFYMEDIA             = WM_USER + 203;    // wp = hwnd, lp = fn
  2050.     MCIWNDM_NOTIFYERROR             = WM_USER + 205;    // wp = hwnd, lp = error
  2051.  
  2052. {-- Special seek values for START and END ------------------------------------}
  2053.  
  2054.     MCIWND_START                    = -1 ;
  2055.     MCIWND_END                      = -2 ;
  2056.  
  2057. {== VIDEO - Video capture driver interface ===================================}
  2058.  
  2059. type
  2060.     HVIDEO                          = THandle;
  2061.     PHVIDEO                         = ^HVIDEO;
  2062.  
  2063. {-- Error return values ------------------------------------------------------}
  2064.  
  2065. const
  2066.     DV_ERR_OK                       = 0;                    // No error
  2067.     DV_ERR_BASE                     = 1;                    // Error Base 
  2068.     DV_ERR_NONSPECIFIC              = DV_ERR_BASE;
  2069.     DV_ERR_BADFORMAT                = DV_ERR_BASE + 1;      // unsupported video format 
  2070.     DV_ERR_STILLPLAYING             = DV_ERR_BASE + 2;      // still something playing 
  2071.     DV_ERR_UNPREPARED               = DV_ERR_BASE + 3;      // header not prepared 
  2072.     DV_ERR_SYNC                     = DV_ERR_BASE + 4;      // device is synchronous 
  2073.     DV_ERR_TOOMANYCHANNELS          = DV_ERR_BASE + 5;      // number of channels exceeded 
  2074.     DV_ERR_NOTDETECTED              = DV_ERR_BASE + 6;      // HW not detected 
  2075.     DV_ERR_BADINSTALL               = DV_ERR_BASE + 7;      // Can not get Profile 
  2076.     DV_ERR_CREATEPALETTE            = DV_ERR_BASE + 8;
  2077.     DV_ERR_SIZEFIELD                = DV_ERR_BASE + 9;
  2078.     DV_ERR_PARAM1                   = DV_ERR_BASE + 10;
  2079.     DV_ERR_PARAM2                   = DV_ERR_BASE + 11;
  2080.     DV_ERR_CONFIG1                  = DV_ERR_BASE + 12;
  2081.     DV_ERR_CONFIG2                  = DV_ERR_BASE + 13;
  2082.     DV_ERR_FLAGS                    = DV_ERR_BASE + 14;
  2083.     DV_ERR_13                       = DV_ERR_BASE + 15;
  2084.  
  2085.     DV_ERR_NOTSUPPORTED             = DV_ERR_BASE + 16;     // function not suported 
  2086.     DV_ERR_NOMEM                    = DV_ERR_BASE + 17;     // out of memory 
  2087.     DV_ERR_ALLOCATED                = DV_ERR_BASE + 18;     // device is allocated 
  2088.     DV_ERR_BADDEVICEID              = DV_ERR_BASE + 19;
  2089.     DV_ERR_INVALHANDLE              = DV_ERR_BASE + 20;
  2090.     DV_ERR_BADERRNUM                = DV_ERR_BASE + 21;
  2091.     DV_ERR_NO_BUFFERS               = DV_ERR_BASE + 22;     // out of buffers 
  2092.  
  2093.     DV_ERR_MEM_CONFLICT             = DV_ERR_BASE + 23;     // Mem conflict detected 
  2094.     DV_ERR_IO_CONFLICT              = DV_ERR_BASE + 24;     // I/O conflict detected 
  2095.     DV_ERR_DMA_CONFLICT             = DV_ERR_BASE + 25;     // DMA conflict detected
  2096.     DV_ERR_INT_CONFLICT             = DV_ERR_BASE + 26;     // Interrupt conflict detected
  2097.     DV_ERR_PROTECT_ONLY             = DV_ERR_BASE + 27;     // Can not run in standard mode
  2098.     DV_ERR_LASTERROR                = DV_ERR_BASE + 27;
  2099.  
  2100.     DV_ERR_USER_MSG                 = DV_ERR_BASE + 1000;   // Hardware specific errors
  2101.  
  2102. {-- Callback messages --------------------------------------------------------}
  2103.  
  2104. // Note that the values for all installable driver callback messages are
  2105. // identical, (ie. MM_DRVM_DATA has the same value for capture drivers,
  2106. // installable video codecs, and the audio compression manager).
  2107.  
  2108. const
  2109.     DV_VM_OPEN                      = MM_DRVM_OPEN;     // Obsolete messages
  2110.     DV_VM_CLOSE                     = MM_DRVM_CLOSE;
  2111.     DV_VM_DATA                      = MM_DRVM_DATA;
  2112.     DV_VM_ERROR                     = MM_DRVM_ERROR;
  2113.  
  2114. {== Structures ===============================================================}
  2115.  
  2116. {-- Video data block header --------------------------------------------------}
  2117.  
  2118. type
  2119.     PVIDEOHDR               = ^TVIDEOHDR;
  2120.     TVIDEOHDR               = record
  2121.         lpData              : PBYTE;                // pointer to locked data buffer
  2122.         dwBufferLength      : DWORD;                // Length of data buffer
  2123.         dwBytesUsed         : DWORD;                // Bytes actually used
  2124.         dwTimeCaptured      : DWORD;                // Milliseconds from start of stream
  2125.         dwUser              : DWORD;                // for client's use
  2126.         dwFlags             : DWORD;                // assorted flags (see defines)
  2127.         dwReserved          : array[0..3] of DWORD; // reserved for driver
  2128.     end;
  2129.  
  2130. {-- dwFlags field of VIDEOHDR ------------------------------------------------}
  2131.  
  2132. const
  2133.     VHDR_DONE                       = $00000001;    // Done bit
  2134.     VHDR_PREPARED                   = $00000002;    // Set if this header has been prepared
  2135.     VHDR_INQUEUE                    = $00000004;    // Reserved for driver
  2136.     VHDR_KEYFRAME                   = $00000008;    // Key Frame
  2137.  
  2138. {-- Channel capabilities structure -------------------------------------------}
  2139.  
  2140. type
  2141.     PCHANNEL_CAPS           = ^TCHANNEL_CAPS;
  2142.     TCHANNEL_CAPS           = record
  2143.         dwFlags             : DWORD;    // Capability flags
  2144.         dwSrcRectXMod       : DWORD;    // Granularity of src rect in x
  2145.         dwSrcRectYMod       : DWORD;    // Granularity of src rect in y
  2146.         dwSrcRectWidthMod   : DWORD;    // Granularity of src rect width
  2147.         dwSrcRectHeightMod  : DWORD;    // Granularity of src rect height
  2148.         dwDstRectXMod       : DWORD;    // Granularity of dst rect in x
  2149.         dwDstRectYMod       : DWORD;    // Granularity of dst rect in y
  2150.         dwDstRectWidthMod   : DWORD;    // Granularity of dst rect width
  2151.         dwDstRectHeightMod  : DWORD;    // Granularity of dst rect height
  2152.     end;
  2153.  
  2154. {-- dwFlags of CHANNEL_CAPS --------------------------------------------------}
  2155.  
  2156. const
  2157.     VCAPS_OVERLAY                   = $00000001;    // overlay channel 
  2158.     VCAPS_SRC_CAN_CLIP              = $00000002;    // src rect can clip
  2159.     VCAPS_DST_CAN_CLIP              = $00000004;    // dst rect can clip
  2160.     VCAPS_CAN_SCALE                 = $00000008;    // allows src != dst
  2161.  
  2162. {== API flags ================================================================}
  2163.  
  2164. {-- Types of channels to open with the videoOpen function --------------------}
  2165.  
  2166. const
  2167.     VIDEO_EXTERNALIN                = $0001;
  2168.     VIDEO_EXTERNALOUT               = $0002;
  2169.     VIDEO_IN                        = $0004;
  2170.     VIDEO_OUT                       = $0008;
  2171.  
  2172. {-- Is a driver dialog available for this channel ----------------------------}
  2173.  
  2174.     VIDEO_DLG_QUERY                 = $0010;
  2175.  
  2176. {-- videoConfigure (both GET and SET) ----------------------------------------}
  2177.  
  2178.     VIDEO_CONFIGURE_QUERY           = $8000;
  2179.  
  2180. {-- videoConfigure (SET only) ------------------------------------------------}
  2181.  
  2182.     VIDEO_CONFIGURE_SET             = $1000;
  2183.  
  2184. {-- videoConfigure (GET only) ------------------------------------------------}
  2185.  
  2186.     VIDEO_CONFIGURE_GET             = $2000;
  2187.     VIDEO_CONFIGURE_QUERYSIZE       = $0001;
  2188.  
  2189.     VIDEO_CONFIGURE_CURRENT         = $0010;
  2190.     VIDEO_CONFIGURE_NOMINAL         = $0020;
  2191.     VIDEO_CONFIGURE_MIN             = $0040;
  2192.     VIDEO_CONFIGURE_MAX             = $0080;
  2193.  
  2194. {== Configure messages =======================================================}
  2195.  
  2196.     DVM_USER                        = $4000;
  2197.  
  2198.     DVM_CONFIGURE_START             = $1000;
  2199.     DVM_CONFIGURE_END               = $1FFF;
  2200.  
  2201.     DVM_PALETTE                     = DVM_CONFIGURE_START + 1;
  2202.     DVM_FORMAT                      = DVM_CONFIGURE_START + 2;
  2203.     DVM_PALETTERGB555               = DVM_CONFIGURE_START + 3;
  2204.     DVM_SRC_RECT                    = DVM_CONFIGURE_START + 4;
  2205.     DVM_DST_RECT                    = DVM_CONFIGURE_START + 5;
  2206.  
  2207. {== AVICAP - Window class for AVI capture ====================================}
  2208.  
  2209. function    AVICapSM(hwnd: HWND; m: UINT; w: WPARAM; l: LPARAM): DWORD;
  2210.  
  2211. {-- Window messages WM_CAP... which can be sent to an AVICAP window ----------}
  2212.  
  2213. // UNICODE
  2214. //
  2215. // The Win32 version of AVICAP on NT supports UNICODE applications:
  2216. // for each API or message that takes a char or string parameter, there are
  2217. // two versions, ApiNameA and ApiNameW. The default name ApiName is #defined
  2218. // to one or other depending on whether UNICODE is defined. Apps can call
  2219. // the A and W apis directly, and mix them.
  2220. //
  2221. // The 32-bit AVICAP on NT uses unicode exclusively internally.
  2222. // ApiNameA() will be implemented as a call to ApiNameW() together with
  2223. // translation of strings.
  2224.  
  2225. // Defines start of the message range
  2226. const
  2227.     WM_CAP_START                    = WM_USER;
  2228.     WM_CAP_UNICODE_START            = WM_USER + 100;
  2229.  
  2230.     WM_CAP_GET_CAPSTREAMPTR         = WM_CAP_START + 1;
  2231.  
  2232.     WM_CAP_SET_CALLBACK_ERRORW      = WM_CAP_UNICODE_START + 2;
  2233.     WM_CAP_SET_CALLBACK_STATUSW     = WM_CAP_UNICODE_START + 3;
  2234.     WM_CAP_SET_CALLBACK_ERRORA      = WM_CAP_START + 2;
  2235.     WM_CAP_SET_CALLBACK_STATUSA     = WM_CAP_START + 3;
  2236.     WM_CAP_SET_CALLBACK_ERROR       = WM_CAP_SET_CALLBACK_ERRORA;
  2237.     WM_CAP_SET_CALLBACK_STATUS      = WM_CAP_SET_CALLBACK_STATUSA;
  2238.  
  2239.     WM_CAP_SET_CALLBACK_YIELD       = WM_CAP_START + 4;
  2240.     WM_CAP_SET_CALLBACK_FRAME       = WM_CAP_START + 5;
  2241.     WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6;
  2242.     WM_CAP_SET_CALLBACK_WAVESTREAM  = WM_CAP_START + 7;
  2243.     WM_CAP_GET_USER_DATA            = WM_CAP_START + 8;
  2244.     WM_CAP_SET_USER_DATA            = WM_CAP_START + 9;
  2245.  
  2246.     WM_CAP_DRIVER_CONNECT           = WM_CAP_START + 10;
  2247.     WM_CAP_DRIVER_DISCONNECT        = WM_CAP_START + 11;
  2248.  
  2249.     WM_CAP_DRIVER_GET_NAMEA         = WM_CAP_START + 12;
  2250.     WM_CAP_DRIVER_GET_VERSIONA      = WM_CAP_START + 13;
  2251.     WM_CAP_DRIVER_GET_NAMEW         = WM_CAP_UNICODE_START + 12;
  2252.     WM_CAP_DRIVER_GET_VERSIONW      = WM_CAP_UNICODE_START + 13;
  2253.     WM_CAP_DRIVER_GET_NAME          = WM_CAP_DRIVER_GET_NAMEA;
  2254.     WM_CAP_DRIVER_GET_VERSION       = WM_CAP_DRIVER_GET_VERSIONA;
  2255.  
  2256.     WM_CAP_DRIVER_GET_CAPS          = WM_CAP_START + 14;
  2257.  
  2258.     WM_CAP_FILE_SET_CAPTURE_FILEA   = WM_CAP_START + 20;
  2259.     WM_CAP_FILE_GET_CAPTURE_FILEA   = WM_CAP_START + 21;
  2260.     WM_CAP_FILE_SAVEASA             = WM_CAP_START + 23;
  2261.     WM_CAP_FILE_SAVEDIBA            = WM_CAP_START + 25;
  2262.     WM_CAP_FILE_SET_CAPTURE_FILEW   = WM_CAP_UNICODE_START + 20;
  2263.     WM_CAP_FILE_GET_CAPTURE_FILEW   = WM_CAP_UNICODE_START + 21;
  2264.     WM_CAP_FILE_SAVEASW             = WM_CAP_UNICODE_START + 23;
  2265.     WM_CAP_FILE_SAVEDIBW            = WM_CAP_UNICODE_START + 25;
  2266.     WM_CAP_FILE_SET_CAPTURE_FILE    = WM_CAP_FILE_SET_CAPTURE_FILEA;
  2267.     WM_CAP_FILE_GET_CAPTURE_FILE    = WM_CAP_FILE_GET_CAPTURE_FILEA;
  2268.     WM_CAP_FILE_SAVEAS              = WM_CAP_FILE_SAVEASA;
  2269.     WM_CAP_FILE_SAVEDIB             = WM_CAP_FILE_SAVEDIBA;
  2270.  
  2271.     // out of order to save on ifdefs
  2272.  
  2273.     WM_CAP_FILE_ALLOCATE            = WM_CAP_START + 22;
  2274.     WM_CAP_FILE_SET_INFOCHUNK       = WM_CAP_START + 24;
  2275.  
  2276.     WM_CAP_EDIT_COPY                = WM_CAP_START + 30;
  2277.  
  2278.     WM_CAP_SET_AUDIOFORMAT          = WM_CAP_START + 35;
  2279.     WM_CAP_GET_AUDIOFORMAT          = WM_CAP_START + 36;
  2280.  
  2281.     WM_CAP_DLG_VIDEOFORMAT          = WM_CAP_START + 41;
  2282.     WM_CAP_DLG_VIDEOSOURCE          = WM_CAP_START + 42;
  2283.     WM_CAP_DLG_VIDEODISPLAY         = WM_CAP_START + 43;
  2284.     WM_CAP_GET_VIDEOFORMAT          = WM_CAP_START + 44;
  2285.     WM_CAP_SET_VIDEOFORMAT          = WM_CAP_START + 45;
  2286.     WM_CAP_DLG_VIDEOCOMPRESSION     = WM_CAP_START + 46;
  2287.  
  2288.     WM_CAP_SET_PREVIEW              = WM_CAP_START + 50;
  2289.     WM_CAP_SET_OVERLAY              = WM_CAP_START + 51;
  2290.     WM_CAP_SET_PREVIEWRATE          = WM_CAP_START + 52;
  2291.     WM_CAP_SET_SCALE                = WM_CAP_START + 53;
  2292.     WM_CAP_GET_STATUS               = WM_CAP_START + 54;
  2293.     WM_CAP_SET_SCROLL               = WM_CAP_START + 55;
  2294.  
  2295.     WM_CAP_GRAB_FRAME               = WM_CAP_START + 60;
  2296.     WM_CAP_GRAB_FRAME_NOSTOP        = WM_CAP_START + 61;
  2297.  
  2298.     WM_CAP_SEQUENCE                 = WM_CAP_START + 62;
  2299.     WM_CAP_SEQUENCE_NOFILE          = WM_CAP_START + 63;
  2300.     WM_CAP_SET_SEQUENCE_SETUP       = WM_CAP_START + 64;
  2301.     WM_CAP_GET_SEQUENCE_SETUP       = WM_CAP_START + 65;
  2302.  
  2303.     WM_CAP_SET_MCI_DEVICEA          = WM_CAP_START + 66;
  2304.     WM_CAP_GET_MCI_DEVICEA          = WM_CAP_START + 67;
  2305.     WM_CAP_SET_MCI_DEVICEW          = WM_CAP_UNICODE_START + 66;
  2306.     WM_CAP_GET_MCI_DEVICEW          = WM_CAP_UNICODE_START + 67;
  2307.     WM_CAP_SET_MCI_DEVICE           = WM_CAP_SET_MCI_DEVICEA;
  2308.     WM_CAP_GET_MCI_DEVICE           = WM_CAP_GET_MCI_DEVICEA;
  2309.  
  2310.     WM_CAP_STOP                     = WM_CAP_START + 68;
  2311.     WM_CAP_ABORT                    = WM_CAP_START + 69;
  2312.  
  2313.     WM_CAP_SINGLE_FRAME_OPEN        = WM_CAP_START + 70;
  2314.     WM_CAP_SINGLE_FRAME_CLOSE       = WM_CAP_START + 71;
  2315.     WM_CAP_SINGLE_FRAME             = WM_CAP_START + 72;
  2316.  
  2317.     WM_CAP_PAL_OPENA                = WM_CAP_START + 80;
  2318.     WM_CAP_PAL_SAVEA                = WM_CAP_START + 81;
  2319.     WM_CAP_PAL_OPENW                = WM_CAP_UNICODE_START + 80;
  2320.     WM_CAP_PAL_SAVEW                = WM_CAP_UNICODE_START + 81;
  2321.     WM_CAP_PAL_OPEN                 = WM_CAP_PAL_OPENA;
  2322.     WM_CAP_PAL_SAVE                 = WM_CAP_PAL_SAVEA;
  2323.  
  2324.     WM_CAP_PAL_PASTE                = WM_CAP_START + 82;
  2325.     WM_CAP_PAL_AUTOCREATE           = WM_CAP_START + 83;
  2326.     WM_CAP_PAL_MANUALCREATE         = WM_CAP_START + 84;
  2327.  
  2328.     // Following added post VFW 1.1
  2329.  
  2330.     WM_CAP_SET_CALLBACK_CAPCONTROL  = WM_CAP_START + 85;
  2331.  
  2332.     // Defines end of the message range
  2333.  
  2334.     WM_CAP_UNICODE_END              = WM_CAP_PAL_SAVEW;
  2335.     WM_CAP_END                      = WM_CAP_UNICODE_END;
  2336.  
  2337. {-- Callback definitions -----------------------------------------------------}
  2338.  
  2339. type
  2340.     TCAPYIELDCALLBACK               = function(hWnd: HWND): DWORD; stdcall;
  2341.  
  2342.     TCAPSTATUSCALLBACKW             = function(hWnd: HWND; nID: int; lpsz: LPCWSTR): DWORD; stdcall;
  2343.     TCAPERRORCALLBACKW              = function(hWnd: HWND; nID: int; lpsz: LPCWSTR): DWORD; stdcall;
  2344.     TCAPSTATUSCALLBACKA             = function(hWnd: HWND; nID: int; lpsz: LPCSTR): DWORD; stdcall;
  2345.     TCAPERRORCALLBACKA              = function(hWnd: HWND; nID: int; lpsz: LPCSTR): DWORD; stdcall;
  2346.  
  2347.     TCAPSTATUSCALLBACK              = TCAPSTATUSCALLBACKA;
  2348.     TCAPERRORCALLBACK               = TCAPERRORCALLBACKA;
  2349.  
  2350.     TCAPVIDEOCALLBACK               = function(hWnd: HWND; lpVHdr: PVIDEOHDR): DWORD; stdcall;
  2351.     TCAPWAVECALLBACK                = function(hWnd: HWND; lpWHdr: PWAVEHDR): DWORD; stdcall;
  2352.     TCAPCONTROLCALLBACK             = function(hWnd: HWND; nState: int): DWORD; stdcall;
  2353.  
  2354. {-- Structures ---------------------------------------------------------------}
  2355.  
  2356. type
  2357.     PCAPDRIVERCAPS                  = ^TCAPDRIVERCAPS;
  2358.     TCAPDRIVERCAPS                  = record
  2359.         wDeviceIndex                : UINT;     // Driver index in system.ini
  2360.         fHasOverlay                 : BOOL;     // Can device overlay?
  2361.         fHasDlgVideoSource          : BOOL;     // Has Video source dlg?
  2362.         fHasDlgVideoFormat          : BOOL;     // Has Format dlg?
  2363.         fHasDlgVideoDisplay         : BOOL;     // Has External out dlg?
  2364.         fCaptureInitialized         : BOOL;     // Driver ready to capture?
  2365.         fDriverSuppliesPalettes     : BOOL;     // Can driver make palettes?
  2366.  
  2367.         // following always NULL on Win32.
  2368.         hVideoIn                    : THANDLE;   // Driver In channel
  2369.         hVideoOut                   : THANDLE;   // Driver Out channel
  2370.         hVideoExtIn                 : THANDLE;   // Driver Ext In channel
  2371.         hVideoExtOut                : THANDLE;   // Driver Ext Out channel
  2372.     end;
  2373.  
  2374.     PCAPSTATUS                      = ^TCAPSTATUS;
  2375.     TCAPSTATUS                      = record
  2376.         uiImageWidth                : UINT    ; // Width of the image
  2377.         uiImageHeight               : UINT    ; // Height of the image
  2378.         fLiveWindow                 : BOOL    ; // Now Previewing video?
  2379.         fOverlayWindow              : BOOL    ; // Now Overlaying video?
  2380.         fScale                      : BOOL    ; // Scale image to client?
  2381.         ptScroll                    : TPOINT  ; // Scroll position
  2382.         fUsingDefaultPalette        : BOOL    ; // Using default driver palette?
  2383.         fAudioHardware              : BOOL    ; // Audio hardware present?
  2384.         fCapFileExists              : BOOL    ; // Does capture file exist?
  2385.         dwCurrentVideoFrame         : DWORD   ; // # of video frames cap'td
  2386.         dwCurrentVideoFramesDropped : DWORD   ; // # of video frames dropped
  2387.         dwCurrentWaveSamples        : DWORD   ; // # of wave samples cap'td
  2388.         dwCurrentTimeElapsedMS      : DWORD   ; // Elapsed capture duration
  2389.         hPalCurrent                 : HPALETTE; // Current palette in use
  2390.         fCapturingNow               : BOOL    ; // Capture in progress?
  2391.         dwReturn                    : DWORD   ; // Error value after any operation
  2392.         wNumVideoAllocated          : UINT    ; // Actual number of video buffers
  2393.         wNumAudioAllocated          : UINT    ; // Actual number of audio buffers
  2394.     end;
  2395.  
  2396.     // Default values in parenthesis
  2397.  
  2398.     PCAPTUREPARMS                   = ^TCAPTUREPARMS;
  2399.     TCAPTUREPARMS                   = record
  2400.         dwRequestMicroSecPerFrame   : DWORD ;   // Requested capture rate
  2401.         fMakeUserHitOKToCapture     : BOOL  ;   // Show "Hit OK to cap" dlg?
  2402.         wPercentDropForError        : UINT  ;   // Give error msg if > (10%)
  2403.         fYield                      : BOOL  ;   // Capture via background task?
  2404.         dwIndexSize                 : DWORD ;   // Max index size in frames (32K)
  2405.         wChunkGranularity           : UINT  ;   // Junk chunk granularity (2K)
  2406.         fUsingDOSMemory             : BOOL  ;   // Use DOS buffers?
  2407.         wNumVideoRequested          : UINT  ;   // # video buffers, If 0, autocalc
  2408.         fCaptureAudio               : BOOL  ;   // Capture audio?
  2409.         wNumAudioRequested          : UINT  ;   // # audio buffers, If 0, autocalc
  2410.         vKeyAbort                   : UINT  ;   // Virtual key causing abort
  2411.         fAbortLeftMouse             : BOOL  ;   // Abort on left mouse?
  2412.         fAbortRightMouse            : BOOL  ;   // Abort on right mouse?
  2413.         fLimitEnabled               : BOOL  ;   // Use wTimeLimit?
  2414.         wTimeLimit                  : UINT  ;   // Seconds to capture
  2415.         fMCIControl                 : BOOL  ;   // Use MCI video source?
  2416.         fStepMCIDevice              : BOOL  ;   // Step MCI device?
  2417.         dwMCIStartTime              : DWORD ;   // Time to start in MS
  2418.         dwMCIStopTime               : DWORD ;   // Time to stop in MS
  2419.         fStepCaptureAt2x            : BOOL  ;   // Perform spatial averaging 2x
  2420.         wStepCaptureAverageFrames   : UINT  ;   // Temporal average n Frames
  2421.         dwAudioBufferSize           : DWORD ;   // Size of audio bufs (0 = default)
  2422.         fDisableWriteCache          : BOOL  ;   // Attempt to disable write cache
  2423.         AVStreamMaster              : UINT  ;   // Which stream controls length?
  2424.     end;
  2425.  
  2426. {-- AVStreamMaster -----------------------------------------------------------}
  2427.  
  2428. //  Since Audio and Video streams generally use non-synchronized capture
  2429. //  clocks, this flag determines whether the audio stream is to be considered
  2430. //  the master or controlling clock when writing the AVI file:
  2431. //
  2432. //  AVSTREAMMASTER_AUDIO  - Audio is master, video frame duration is forced
  2433. //                          to match audio duration (VFW 1.0, 1.1 default)
  2434. //  AVSTREAMMASTER_NONE   - No master, audio and video streams may be of
  2435. //                          different lengths
  2436.  
  2437. const
  2438.     AVSTREAMMASTER_AUDIO            = 0;        // Audio master (VFW 1.0, 1.1)
  2439.     AVSTREAMMASTER_NONE             = 1;        // No master
  2440.  
  2441. type
  2442.     PCAPINFOCHUNK                   = ^TCAPINFOCHUNK;
  2443.     TCAPINFOCHUNK                   = record
  2444.         fccInfoID                   : FOURCC;   // Chunk ID, "ICOP" for copyright
  2445.         lpData                      : PVOID;    // pointer to data
  2446.         cbData                      : DWORD;     // size of lpData
  2447.     end;
  2448.  
  2449. {-- CapControlCallback states ------------------------------------------------}
  2450.  
  2451. const
  2452.     CONTROLCALLBACK_PREROLL         = 1;        // Waiting to start capture 
  2453.     CONTROLCALLBACK_CAPTURING       = 2;        // Now capturing
  2454.  
  2455. {-- Message crackers for above -----------------------------------------------}
  2456.  
  2457. // message wrapper macros are defined for the default messages only. Apps
  2458. // that wish to mix Ansi and UNICODE message sending will have to
  2459. // reference the _A and _W messages directly
  2460.  
  2461. function    capSetCallbackOnError(hwnd: HWND; fpProc: TCAPERRORCALLBACK): BOOL;
  2462. function    capSetCallbackOnStatus(hwnd: HWND; fpProc: TCAPSTATUSCALLBACK): BOOL;
  2463. function    capSetCallbackOnYield(hwnd: HWND; fpProc: TCAPYIELDCALLBACK): BOOL;
  2464. function    capSetCallbackOnFrame(hwnd: HWND; fpProc: TCAPVIDEOCALLBACK): BOOL;
  2465. function    capSetCallbackOnVideoStream(hwnd: HWND; fpProc: TCAPVIDEOCALLBACK): BOOL;
  2466. function    capSetCallbackOnWaveStream(hwnd: HWND; fpProc: TCAPWAVECALLBACK): BOOL;
  2467. function    capSetCallbackOnCapControl(hwnd: HWND; fpProc: TCAPCONTROLCALLBACK): BOOL;
  2468.  
  2469. function    capSetUserData(hwnd: HWND; lUser: DWORD): BOOL;
  2470. function    capGetUserData(hwnd: HWND): DWORD;
  2471.  
  2472. function    capDriverConnect(hwnd: HWND; i: INT): BOOL;
  2473. function    capDriverDisconnect(hwnd: HWND): BOOL;
  2474. function    capDriverGetName(hwnd: HWND; szName: LPSTR; wSize: WORD): BOOL;
  2475. function    capDriverGetVersion(hwnd: HWND; szVer: LPSTR; wSize: WORD): BOOL;
  2476. function    capDriverGetCaps(hwnd: HWND; s: PCAPDRIVERCAPS; wSize: WORD): BOOL;
  2477.  
  2478. function    capFileSetCaptureFile(hwnd: HWND; szName: LPCSTR): BOOL;
  2479. function    capFileGetCaptureFile(hwnd: HWND; szName: LPSTR; wSize: WORD): BOOL;
  2480. function    capFileAlloc(hwnd: HWND; dwSize: DWORD): BOOL;
  2481. function    capFileSaveAs(hwnd: HWND; szName: LPCSTR): BOOL;
  2482. function    capFileSetInfoChunk(hwnd: HWND; lpInfoChunk: PCAPINFOCHUNK): BOOL;
  2483. function    capFileSaveDIB(hwnd: HWND; szName: LPCSTR): BOOL;
  2484.  
  2485. function    capEditCopy(hwnd: HWND): BOOL;
  2486.  
  2487. function    capSetAudioFormat(hwnd: HWND; s: PWAVEFORMATEX; wSize: WORD): BOOL;
  2488. function    capGetAudioFormat(hwnd: HWND; s: PWAVEFORMATEX; wSize: WORD): DWORD;
  2489. function    capGetAudioFormatSize(hwnd: HWND): DWORD;
  2490.  
  2491. function    capDlgVideoFormat(hwnd: HWND): BOOL;
  2492. function    capDlgVideoSource(hwnd: HWND): BOOL;
  2493. function    capDlgVideoDisplay(hwnd: HWND): BOOL;
  2494. function    capDlgVideoCompression(hwnd: HWND): BOOL;
  2495.  
  2496. function    capGetVideoFormat(hwnd: HWND; s: PVOID; wSize: WORD): DWORD;
  2497. function    capGetVideoFormatSize(hwnd: HWND): DWORD;
  2498. function    capSetVideoFormat(hwnd: HWND; s: PVOID; wSize: WORD): BOOL;
  2499.  
  2500. function    capPreview(hwnd: HWND; f: BOOL): BOOL;
  2501. function    capPreviewRate(hwnd: HWND; wMS: WORD): BOOL;
  2502. function    capOverlay(hwnd: HWND; f: BOOL): BOOL;
  2503. function    capPreviewScale(hwnd: HWND; f: BOOL): BOOL;
  2504. function    capGetStatus(hwnd: HWND; s: PCAPSTATUS; wSize: WORD): BOOL;
  2505. function    capSetScrollPos(hwnd: HWND; lpP: PPOINT): BOOL;
  2506.  
  2507. function    capGrabFrame(hwnd: HWND): BOOL;
  2508. function    capGrabFrameNoStop(hwnd: HWND): BOOL;
  2509.  
  2510. function    capCaptureSequence(hwnd: HWND): BOOL;
  2511. function    capCaptureSequenceNoFile(hwnd: HWND): BOOL;
  2512. function    capCaptureStop(hwnd: HWND): BOOL;
  2513. function    capCaptureAbort(hwnd: HWND): BOOL;
  2514.  
  2515. function    capCaptureSingleFrameOpen(hwnd: HWND): BOOL;
  2516. function    capCaptureSingleFrameClose(hwnd: HWND): BOOL;
  2517. function    capCaptureSingleFrame(hwnd: HWND): BOOL;
  2518.  
  2519. function    capCaptureGetSetup(hwnd: HWND; s: PCAPTUREPARMS; wSize: WORD): BOOL;
  2520. function    capCaptureSetSetup(hwnd: HWND; s: PCAPTUREPARMS; wSize: WORD): BOOL;
  2521.  
  2522. function    capSetMCIDeviceName(hwnd: HWND; szName: LPCSTR): BOOL;
  2523. function    capGetMCIDeviceName(hwnd: HWND; szName: LPSTR; wSize: WORD): BOOL;
  2524.  
  2525. function    capPaletteOpen(hwnd: HWND; szName: LPCSTR): BOOL;
  2526. function    capPaletteSave(hwnd: HWND; szName: LPCSTR): BOOL;
  2527. function    capPalettePaste(hwnd: HWND): BOOL;
  2528. function    capPaletteAuto(hwnd: HWND; iFrames, iColors: INT): BOOL;
  2529. function    capPaletteManual(hwnd: HWND; fGrab: BOOL; iColors: INT): BOOL;
  2530.  
  2531. {-- The only exported functions from AVICAP.DLL ------------------------------}
  2532.  
  2533. function    capCreateCaptureWindowA(
  2534.     lpszWindowName      : LPCSTR;
  2535.     dwStyle             : DWORD;
  2536.     x, y                : int;
  2537.     nWidth, nHeight     : int;
  2538.     hwndParent          : HWND;
  2539.     nID                 : int
  2540.     ): HWND; stdcall;
  2541.  
  2542. function    capGetDriverDescriptionA(
  2543.     wDriverIndex        : UINT;
  2544.     lpszName            : LPSTR;
  2545.     cbName              : int;
  2546.     lpszVer             : LPSTR;
  2547.     cbVer               : int
  2548.     ): BOOL; stdcall;
  2549.  
  2550. function    capCreateCaptureWindowW(
  2551.     lpszWindowName      : LPCWSTR;
  2552.     dwStyle             : DWORD;
  2553.     x, y                : int;
  2554.     nWidth, nHeight     : int;
  2555.     hwndParent          : HWND;
  2556.     nID                 : int
  2557.     ): HWND; stdcall;
  2558.  
  2559. function    capGetDriverDescriptionW(
  2560.     wDriverIndex        : UINT;
  2561.     lpszName            : LPWSTR;
  2562.     cbName              : int;
  2563.     lpszVer             : LPWSTR;
  2564.     cbVer               : int
  2565.     ): BOOL; stdcall;
  2566.  
  2567. function    capCreateCaptureWindow(
  2568.     lpszWindowName      : LPCSTR;
  2569.     dwStyle             : DWORD;
  2570.     x, y                : int;
  2571.     nWidth, nHeight     : int;
  2572.     hwndParent          : HWND;
  2573.     nID                 : int
  2574.     ): HWND; stdcall; // capCreateCaptureWindowA
  2575.  
  2576. function    capGetDriverDescription(
  2577.     wDriverIndex        : UINT;
  2578.     lpszName            : LPSTR;
  2579.     cbName              : int;
  2580.     lpszVer             : LPSTR;
  2581.     cbVer               : int
  2582.     ): BOOL; stdcall; // capGetDriverDescriptionA
  2583.  
  2584. {-- New information chunk IDs ------------------------------------------------}
  2585.  
  2586. const
  2587.     infotypeDIGITIZATION_TIME       = $54494449; // mmioFOURCC ('I','D','I','T')
  2588.     infotypeSMPTE_TIME              = $504D5349; // mmioFOURCC ('I','S','M','P')
  2589.  
  2590. {-- String IDs from status and error callbacks -------------------------------}
  2591.  
  2592.     IDS_CAP_BEGIN                   = 300;  // "Capture Start" 
  2593.     IDS_CAP_END                     = 301;  // "Capture End" 
  2594.  
  2595.     IDS_CAP_INFO                    = 401;  // "%s" 
  2596.     IDS_CAP_OUTOFMEM                = 402;  // "Out of memory" 
  2597.     IDS_CAP_FILEEXISTS              = 403;  // "File '%s' exists -- overwrite it?" 
  2598.     IDS_CAP_ERRORPALOPEN            = 404;  // "Error opening palette '%s'" 
  2599.     IDS_CAP_ERRORPALSAVE            = 405;  // "Error saving palette '%s'" 
  2600.     IDS_CAP_ERRORDIBSAVE            = 406;  // "Error saving frame '%s'" 
  2601.     IDS_CAP_DEFAVIEXT               = 407;  // "avi" 
  2602.     IDS_CAP_DEFPALEXT               = 408;  // "pal" 
  2603.     IDS_CAP_CANTOPEN                = 409;  // "Cannot open '%s'"
  2604.     IDS_CAP_SEQ_MSGSTART            = 410;  // "Select OK to start capture\nof video sequence\nto %s."
  2605.     IDS_CAP_SEQ_MSGSTOP             = 411;  // "Hit ESCAPE or click to end capture" 
  2606.  
  2607.     IDS_CAP_VIDEDITERR              = 412;  // "An error occurred while trying to run VidEdit." 
  2608.     IDS_CAP_READONLYFILE            = 413;  // "The file '%s' is a read-only file." 
  2609.     IDS_CAP_WRITEERROR              = 414;  // "Unable to write to file '%s'.\nDisk may be full." 
  2610.     IDS_CAP_NODISKSPACE             = 415;  // "There is no space to create a capture file on the specified device." 
  2611.     IDS_CAP_SETFILESIZE             = 416;  // "Set File Size" 
  2612.     IDS_CAP_SAVEASPERCENT           = 417;  // "SaveAs: %2ld%%  Hit Escape to abort." 
  2613.  
  2614.     IDS_CAP_DRIVER_ERROR            = 418;  // Driver specific error message 
  2615.  
  2616.     IDS_CAP_WAVE_OPEN_ERROR         = 419;  // "Error: Cannot open the wave input device.\nCheck sample size, frequency, and channels." 
  2617.     IDS_CAP_WAVE_ALLOC_ERROR        = 420;  // "Error: Out of memory for wave buffers." 
  2618.     IDS_CAP_WAVE_PREPARE_ERROR      = 421;  // "Error: Cannot prepare wave buffers." 
  2619.     IDS_CAP_WAVE_ADD_ERROR          = 422;  // "Error: Cannot add wave buffers." 
  2620.     IDS_CAP_WAVE_SIZE_ERROR         = 423;  // "Error: Bad wave size." 
  2621.  
  2622.     IDS_CAP_VIDEO_OPEN_ERROR        = 424;  // "Error: Cannot open the video input device." 
  2623.     IDS_CAP_VIDEO_ALLOC_ERROR       = 425;  // "Error: Out of memory for video buffers."
  2624.     IDS_CAP_VIDEO_PREPARE_ERROR     = 426;  // "Error: Cannot prepare video buffers." 
  2625.     IDS_CAP_VIDEO_ADD_ERROR         = 427;  // "Error: Cannot add video buffers." 
  2626.     IDS_CAP_VIDEO_SIZE_ERROR        = 428;  // "Error: Bad video size." 
  2627.  
  2628.     IDS_CAP_FILE_OPEN_ERROR         = 429;  // "Error: Cannot open capture file." 
  2629.     IDS_CAP_FILE_WRITE_ERROR        = 430;  // "Error: Cannot write to capture file.  Disk may be full." 
  2630.     IDS_CAP_RECORDING_ERROR         = 431;  // "Error: Cannot write to capture file.  Data rate too high or disk full." 
  2631.     IDS_CAP_RECORDING_ERROR2        = 432;  // "Error while recording" 
  2632.     IDS_CAP_AVI_INIT_ERROR          = 433;  // "Error: Unable to initialize for capture."
  2633.     IDS_CAP_NO_FRAME_CAP_ERROR      = 434;  // "Warning: No frames captured.\nConfirm that vertical sync interrupts\nare configured and enabled." 
  2634.     IDS_CAP_NO_PALETTE_WARN         = 435;  // "Warning: Using default palette." 
  2635.     IDS_CAP_MCI_CONTROL_ERROR       = 436;  // "Error: Unable to access MCI device." 
  2636.     IDS_CAP_MCI_CANT_STEP_ERROR     = 437;  // "Error: Unable to step MCI device." 
  2637.     IDS_CAP_NO_AUDIO_CAP_ERROR      = 438;  // "Error: No audio data captured.\nCheck audio card settings." 
  2638.     IDS_CAP_AVI_DRAWDIB_ERROR       = 439;  // "Error: Unable to draw this data format."
  2639.     IDS_CAP_COMPRESSOR_ERROR        = 440;  // "Error: Unable to initialize compressor."
  2640.     IDS_CAP_AUDIO_DROP_ERROR        = 441;  // "Error: Audio data was lost during capture, reduce capture rate."
  2641.  
  2642. {-- Status string IDs --------------------------------------------------------}
  2643.  
  2644.     IDS_CAP_STAT_LIVE_MODE          = 500;  // "Live window" 
  2645.     IDS_CAP_STAT_OVERLAY_MODE       = 501;  // "Overlay window" 
  2646.     IDS_CAP_STAT_CAP_INIT           = 502;  // "Setting up for capture - Please wait" 
  2647.     IDS_CAP_STAT_CAP_FINI           = 503;  // "Finished capture, now writing frame %ld" 
  2648.     IDS_CAP_STAT_PALETTE_BUILD      = 504;  // "Building palette map" 
  2649.     IDS_CAP_STAT_OPTPAL_BUILD       = 505;  // "Computing optimal palette" 
  2650.     IDS_CAP_STAT_I_FRAMES           = 506;  // "%d frames" 
  2651.     IDS_CAP_STAT_L_FRAMES           = 507;  // "%ld frames" 
  2652.     IDS_CAP_STAT_CAP_L_FRAMES       = 508;  // "Captured %ld frames" 
  2653.     IDS_CAP_STAT_CAP_AUDIO          = 509;  // "Capturing audio" 
  2654.     IDS_CAP_STAT_VIDEOCURRENT       = 510;  // "Captured %ld frames (%ld dropped) %d.%03d sec." 
  2655.     IDS_CAP_STAT_VIDEOAUDIO         = 511;  // "Captured %d.%03d sec.  %ld frames (%ld dropped) (%d.%03d fps).  %ld audio bytes (%d,%03d sps)" 
  2656.     IDS_CAP_STAT_VIDEOONLY          = 512;  // "Captured %d.%03d sec.  %ld frames (%ld dropped) (%d.%03d fps)" 
  2657.     IDS_CAP_STAT_FRAMESDROPPED      = 513;  // "Dropped %ld of %ld frames (%d.%02d%%) during capture."
  2658.  
  2659. {== FilePreview dialog =======================================================}
  2660.  
  2661. function    GetOpenFileNamePreviewA(lpofn: POPENFILENAMEA): BOOL; stdcall;
  2662. function    GetSaveFileNamePreviewA(lpofn: POPENFILENAMEA): BOOL; stdcall;
  2663.  
  2664. function    GetOpenFileNamePreviewW(lpofn: POPENFILENAMEW): BOOL; stdcall;
  2665. function    GetSaveFileNamePreviewW(lpofn: POPENFILENAMEW): BOOL; stdcall;
  2666.  
  2667. function    GetOpenFileNamePreview(lpofn: POPENFILENAMEA): BOOL; stdcall; // GetOpenFileNamePreviewA
  2668. function    GetSaveFileNamePreview(lpofn: POPENFILENAMEA): BOOL; stdcall; // GetSaveFileNamePreviewA
  2669.  
  2670. implementation
  2671.  
  2672. function    MKFOURCC( ch0, ch1, ch2, ch3: Char ): FOURCC;
  2673. begin
  2674.     Result := (DWord(Ord(ch0))) or
  2675.               (DWord(Ord(ch1)) shl 8) or
  2676.               (DWord(Ord(ch2)) shl 16) or
  2677.               (DWord(Ord(ch3)) shl 24);
  2678. end;
  2679.  
  2680. function    mmioFOURCC( ch0, ch1, ch2, ch3: Char ): FOURCC;
  2681. begin
  2682.     Result := MKFOURCC(ch0,ch1,ch2,ch3);
  2683. end;
  2684.  
  2685. function    aviTWOCC(ch0, ch1: Char): TWOCC;
  2686. begin
  2687.     Result := (Word(Ord(ch0))) or
  2688.               (Word(Ord(ch1)) shl 8);
  2689. end;
  2690.  
  2691. {-- Query macros -------------------------------------------------------------}
  2692.  
  2693. function    ICQueryAbout(hic: HIC): BOOL;
  2694. begin
  2695.     Result := ICSendMessage(hic, ICM_ABOUT, -1, ICMF_ABOUT_QUERY) = ICERR_OK;
  2696. end;
  2697.  
  2698. function    ICAbout(hic: HIC; hwnd: HWND): DWORD;
  2699. begin
  2700.     Result := ICSendMessage(hic, ICM_ABOUT, hwnd, 0);
  2701. end;
  2702.  
  2703. function    ICQueryConfigure(hic: HIC): BOOL;
  2704. begin
  2705.     Result := ICSendMessage(hic, ICM_CONFIGURE, -1, ICMF_CONFIGURE_QUERY) = ICERR_OK;
  2706. end;
  2707.  
  2708. function    ICConfigure(hic: HIC; hwnd: HWND): DWORD;
  2709. begin
  2710.     Result := ICSendMessage(hic, ICM_CONFIGURE, hwnd, 0);
  2711. end;
  2712.  
  2713. {-- Get/Set state macros -----------------------------------------------------}
  2714.  
  2715. function    ICGetState(hic: HIC; pv: PVOID; cb: DWORD): DWORD;
  2716. begin
  2717.     Result := ICSendMessage(hic, ICM_GETSTATE, DWORD(pv), cb);
  2718. end;
  2719.  
  2720. function    ICSetState(hic: HIC; pv: PVOID; cb: DWORD): DWORD;
  2721. begin
  2722.     Result := ICSendMessage(hic, ICM_SETSTATE, DWORD(pv), cb);
  2723. end;
  2724.  
  2725. function    ICGetStateSize(hic: HIC): DWORD;
  2726. begin
  2727.     Result := ICGetState(hic, nil, 0);
  2728. end;
  2729.  
  2730. {-- Get value macros ---------------------------------------------------------}
  2731.  
  2732. function    ICGetDefaultQuality(hic: HIC): DWORD;
  2733. begin
  2734.     ICSendMessage(hic, ICM_GETDEFAULTQUALITY, DWORD(@Result), sizeof(Result));
  2735. end;
  2736.  
  2737. function    ICGetDefaultKeyFrameRate(hic: HIC): DWORD;
  2738. begin
  2739.     ICSendMessage(hic, ICM_GETDEFAULTKEYFRAMERATE, DWORD(@Result), sizeof(Result));
  2740. end;
  2741.  
  2742. {-- Draw window macro --------------------------------------------------------}
  2743.  
  2744. function    ICDrawWindow(hic: HIC; prc: PRECT): DWORD;
  2745. begin
  2746.     Result := ICSendMessage(hic, ICM_DRAW_WINDOW, DWORD(prc), sizeof(prc^));
  2747. end;
  2748.  
  2749. {-- ICCompressBegin() - start compression from a source fmt to a dest fmt ----}
  2750.  
  2751. function    ICCompressBegin(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  2752. begin
  2753.     Result := ICSendMessage(hic, ICM_COMPRESS_BEGIN, DWORD(lpbiInput), DWORD(lpbiOutput));
  2754. end;
  2755.  
  2756. {-- ICCompressQuery() - determines if compression from src to dst is supp ----}
  2757.  
  2758. function    ICCompressQuery(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  2759. begin
  2760.     Result := ICSendMessage(hic, ICM_COMPRESS_QUERY, DWORD(lpbiInput), DWORD(lpbiOutput));
  2761. end;
  2762.  
  2763. {-- ICCompressGetFormat() - get the output format (fmt of compressed) --------}
  2764.  
  2765. // if lpbiOutput is nil return the size in bytes needed for format.
  2766.  
  2767. function    ICCompressGetFormat(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  2768. begin
  2769.     Result := ICSendMessage(hic, ICM_COMPRESS_GET_FORMAT, DWORD(lpbiInput), DWORD(lpbiOutput));
  2770. end;
  2771.  
  2772. function    ICCompressGetFormatSize(hic: HIC; lpbi: PBITMAPINFOHEADER): DWORD;
  2773. begin
  2774.     Result := ICCompressGetFormat(hic, lpbi, nil);
  2775. end;
  2776.  
  2777. {-- ICCompressSize() - return the maximal size of a compressed frame ---------}
  2778.  
  2779. function    ICCompressGetSize(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  2780. begin
  2781.     Result := ICSendMessage(hic, ICM_COMPRESS_GET_SIZE, DWORD(lpbiInput), DWORD(lpbiOutput));
  2782. end;
  2783.  
  2784. function    ICCompressEnd(hic: HIC): DWORD;
  2785. begin
  2786.     Result := ICSendMessage(hic, ICM_COMPRESS_END, 0, 0);
  2787. end;
  2788.  
  2789. {-- ICDecompressBegin() - start compression from src fmt to a dest fmt -------}
  2790.  
  2791. function    ICDecompressBegin(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  2792. begin
  2793.     Result := ICSendMessage(hic, ICM_DECOMPRESS_BEGIN, DWORD(lpbiInput), DWORD(lpbiOutput));
  2794. end;
  2795.  
  2796. {-- ICDecompressQuery() - determines if compression is supported -------------}
  2797.  
  2798. function    ICDecompressQuery(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  2799. begin
  2800.     Result := ICSendMessage(hic, ICM_DECOMPRESS_QUERY, DWORD(lpbiInput), DWORD(lpbiOutput));
  2801. end;
  2802.  
  2803. {-- ICDecompressGetFormat - get the output fmt (fmt of uncompressed data) ----}
  2804.  
  2805. // if lpbiOutput is NULL return the size in bytes needed for format.
  2806.  
  2807. function    ICDecompressGetFormat(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  2808. begin
  2809.     Result := ICSendMessage(hic, ICM_DECOMPRESS_GET_FORMAT, DWORD(lpbiInput), DWORD(lpbiOutput));
  2810. end;
  2811.  
  2812. function    ICDecompressGetFormatSize(hic: HIC; lpbi: PBITMAPINFOHEADER): DWORD;
  2813. begin
  2814.     Result := ICDecompressGetFormat(hic, lpbi, nil);
  2815. end;
  2816.  
  2817. {-- ICDecompressGetPalette() - get the output palette ------------------------}
  2818.  
  2819. function    ICDecompressGetPalette(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  2820. begin
  2821.     Result := ICSendMessage(hic, ICM_DECOMPRESS_GET_PALETTE, DWORD(lpbiInput), DWORD(lpbiOutput));
  2822. end;
  2823.  
  2824. function    ICDecompressSetPalette(hic: HIC; lpbiPalette: PBITMAPINFOHEADER): DWORD;
  2825. begin
  2826.     Result := ICSendMessage(hic, ICM_DECOMPRESS_SET_PALETTE, DWORD(lpbiPalette), 0);
  2827. end;
  2828.  
  2829. function    ICDecompressEnd(hic: HIC): DWORD;
  2830. begin
  2831.     Result := ICSendMessage(hic, ICM_DECOMPRESS_END, 0, 0);
  2832. end;
  2833.  
  2834. {-- ICDecompressEx() - decompress a single frame -----------------------------}
  2835.  
  2836. function    ICDecompressEx(
  2837.     hic     : HIC;
  2838.     dwFlags : DWORD;
  2839.     lpbiSrc : PBITMAPINFOHEADER;
  2840.     lpSrc   : PVOID;
  2841.     xSrc    : int;
  2842.     ySrc    : int;
  2843.     dxSrc   : int;
  2844.     dySrc   : int;
  2845.     lpbiDst : PBITMAPINFOHEADER;
  2846.     lpDst   : PVOID;
  2847.     xDst    : int;
  2848.     yDst    : int;
  2849.     dxDst   : int;
  2850.     dyDst   : int
  2851.     ): DWORD; stdcall;
  2852. var
  2853.     ic : TICDECOMPRESSEX;
  2854. begin
  2855.     ic.dwFlags  := dwFlags;
  2856.     ic.lpbiSrc  := lpbiSrc;
  2857.     ic.lpSrc    := lpSrc;
  2858.     ic.xSrc     := xSrc;
  2859.     ic.ySrc     := ySrc;
  2860.     ic.dxSrc    := dxSrc;
  2861.     ic.dySrc    := dySrc;
  2862.     ic.lpbiDst  := lpbiDst;
  2863.     ic.lpDst    := lpDst;
  2864.     ic.xDst     := xDst;
  2865.     ic.yDst     := yDst;
  2866.     ic.dxDst    := dxDst;
  2867.     ic.dyDst    := dyDst;
  2868.  
  2869.     // note that ICM swaps round the length and pointer
  2870.     // length in lparam2, pointer in lparam1
  2871.     Result := ICSendMessage(hic, ICM_DECOMPRESSEX, DWORD(@ic), sizeof(ic));
  2872. end;
  2873.  
  2874. {-- ICDecompressExBegin() - start compression from a src fmt to a dest fmt ---}
  2875.  
  2876. function    ICDecompressExBegin(
  2877.     hic     : HIC;
  2878.     dwFlags : DWORD;
  2879.     lpbiSrc : PBITMAPINFOHEADER;
  2880.     lpSrc   : PVOID;
  2881.     xSrc    : int;
  2882.     ySrc    : int;
  2883.     dxSrc   : int;
  2884.     dySrc   : int;
  2885.     lpbiDst : PBITMAPINFOHEADER;
  2886.     lpDst   : PVOID;
  2887.     xDst    : int;
  2888.     yDst    : int;
  2889.     dxDst   : int;
  2890.     dyDst   : int
  2891.     ): DWORD; stdcall;
  2892. var
  2893.     ic : TICDECOMPRESSEX ;
  2894. begin
  2895.     ic.dwFlags  := dwFlags;
  2896.     ic.lpbiSrc  := lpbiSrc;
  2897.     ic.lpSrc    := lpSrc;
  2898.     ic.xSrc     := xSrc;
  2899.     ic.ySrc     := ySrc;
  2900.     ic.dxSrc    := dxSrc;
  2901.     ic.dySrc    := dySrc;
  2902.     ic.lpbiDst  := lpbiDst;
  2903.     ic.lpDst    := lpDst;
  2904.     ic.xDst     := xDst;
  2905.     ic.yDst     := yDst;
  2906.     ic.dxDst    := dxDst;
  2907.     ic.dyDst    := dyDst;
  2908.  
  2909.     // note that ICM swaps round the length and pointer
  2910.     // length in lparam2, pointer in lparam1
  2911.     Result      := ICSendMessage(hic, ICM_DECOMPRESSEX_BEGIN, DWORD(@ic), sizeof(ic));
  2912. end;
  2913.  
  2914. {-- ICDecompressExQuery() ----------------------------------------------------}
  2915.  
  2916. function    ICDecompressExQuery(
  2917.     hic     : HIC;
  2918.     dwFlags : DWORD;
  2919.     lpbiSrc : PBITMAPINFOHEADER;
  2920.     lpSrc   : PVOID;
  2921.     xSrc    : int;
  2922.     ySrc    : int;
  2923.     dxSrc   : int;
  2924.     dySrc   : int;
  2925.     lpbiDst : PBITMAPINFOHEADER;
  2926.     lpDst   : PVOID;
  2927.     xDst    : int;
  2928.     yDst    : int;
  2929.     dxDst   : int;
  2930.     dyDst   : int
  2931.     ): DWORD; stdcall;
  2932. var
  2933.     ic : TICDECOMPRESSEX;
  2934. begin
  2935.     ic.dwFlags  := dwFlags;
  2936.     ic.lpbiSrc  := lpbiSrc;
  2937.     ic.lpSrc    := lpSrc;
  2938.     ic.xSrc     := xSrc;
  2939.     ic.ySrc     := ySrc;
  2940.     ic.dxSrc    := dxSrc;
  2941.     ic.dySrc    := dySrc;
  2942.     ic.lpbiDst  := lpbiDst;
  2943.     ic.lpDst    := lpDst;
  2944.     ic.xDst     := xDst;
  2945.     ic.yDst     := yDst;
  2946.     ic.dxDst    := dxDst;
  2947.     ic.dyDst    := dyDst;
  2948.  
  2949.     // note that ICM swaps round the length and pointer
  2950.     // length in lparam2, pointer in lparam1
  2951.     Result      := ICSendMessage(hic, ICM_DECOMPRESSEX_QUERY, DWORD(@ic), sizeof(ic));
  2952. end;
  2953.  
  2954. function    ICDecompressExEnd(hic: HIC): DWORD;
  2955. begin
  2956.     Result := ICSendMessage(hic, ICM_DECOMPRESSEX_END, 0, 0)
  2957. end;
  2958.  
  2959. function    ICDrawSuggestFormat(
  2960.     hic         : HIC;
  2961.     lpbiIn      : PBITMAPINFOHEADER;
  2962.     lpbiOut     : PBITMAPINFOHEADER;
  2963.     dxSrc       : int;
  2964.     dySrc       : int;
  2965.     dxDst       : int;
  2966.     dyDst       : int;
  2967.     hicDecomp   : HIC
  2968.     ): DWORD; stdcall;
  2969. var
  2970.     ic : TICDRAWSUGGEST;
  2971. begin
  2972.     ic.lpbiIn           := lpbiIn;
  2973.     ic.lpbiSuggest      := lpbiOut;
  2974.     ic.dxSrc            := dxSrc;
  2975.     ic.dySrc            := dySrc;
  2976.     ic.dxDst            := dxDst;
  2977.     ic.dyDst            := dyDst;
  2978.     ic.hicDecompressor  := hicDecomp;
  2979.  
  2980.     // note that ICM swaps round the length and pointer
  2981.     // length in lparam2, pointer in lparam1
  2982.     Result := ICSendMessage(hic, ICM_DRAW_SUGGESTFORMAT, DWORD(@ic), sizeof(ic));
  2983. end;
  2984.  
  2985. {-- ICDrawQuery() - determines if the compressor is willing to render fmt ----}
  2986.  
  2987. function    ICDrawQuery(hic: HIC; lpbiInput: PBITMAPINFOHEADER): DWORD;
  2988. begin
  2989.     Result := ICSendMessage(hic, ICM_DRAW_QUERY, DWORD(lpbiInput), 0);
  2990. end;
  2991.  
  2992. function    ICDrawChangePalette(hic: HIC; lpbiInput: PBITMAPINFOHEADER): DWORD;
  2993. begin
  2994.     Result := ICSendMessage(hic, ICM_DRAW_CHANGEPALETTE, DWORD(lpbiInput), 0);
  2995. end;
  2996.  
  2997. function    ICGetBuffersWanted(hic: HIC; lpdwBuffers: PDWORD): DWORD;
  2998. begin
  2999.     Result := ICSendMessage(hic, ICM_GETBUFFERSWANTED, DWORD(lpdwBuffers), 0);
  3000. end;
  3001.  
  3002. function    ICDrawEnd(hic: HIC): DWORD;
  3003. begin
  3004.     Result := ICSendMessage(hic, ICM_DRAW_END, 0, 0);
  3005. end;
  3006.  
  3007. function    ICDrawStart(hic: HIC): DWORD;
  3008. begin
  3009.     Result := ICSendMessage(hic, ICM_DRAW_START, 0, 0);
  3010. end;
  3011.  
  3012. function    ICDrawStartPlay(hic: HIC; lFrom, lTo: DWORD): DWORD;
  3013. begin
  3014.     Result := ICSendMessage(hic, ICM_DRAW_START_PLAY, lFrom, lTo);
  3015. end;
  3016.  
  3017. function    ICDrawStop(hic: HIC): DWORD;
  3018. begin
  3019.     Result := ICSendMessage(hic, ICM_DRAW_STOP, 0, 0);
  3020. end;
  3021.  
  3022. function    ICDrawStopPlay(hic: HIC): DWORD;
  3023. begin
  3024.     Result := ICSendMessage(hic, ICM_DRAW_STOP_PLAY, 0, 0);
  3025. end;
  3026.  
  3027. function    ICDrawGetTime(hic: HIC; lplTime: PDWORD): DWORD;
  3028. begin
  3029.     Result := ICSendMessage(hic, ICM_DRAW_GETTIME, DWORD(lplTime), 0);
  3030. end;
  3031.  
  3032. function    ICDrawSetTime(hic: HIC; lTime: DWORD): DWORD;
  3033. begin
  3034.     Result := ICSendMessage(hic, ICM_DRAW_SETTIME, lTime, 0);
  3035. end;
  3036.  
  3037. function    ICDrawRealize(hic: HIC; hdc: HDC; fBackground: BOOL): DWORD;
  3038. begin
  3039.     Result := ICSendMessage(hic, ICM_DRAW_REALIZE, DWORD(hdc), DWORD(fBackground));
  3040. end;
  3041.  
  3042. function    ICDrawFlush(hic: HIC): DWORD;
  3043. begin
  3044.     Result := ICSendMessage(hic, ICM_DRAW_FLUSH, 0, 0);
  3045. end;
  3046.  
  3047. function    ICDrawRenderBuffer(hic: HIC): DWORD;
  3048. begin
  3049.     Result := ICSendMessage(hic, ICM_DRAW_RENDERBUFFER, 0, 0);
  3050. end;
  3051.  
  3052. {-- ICSetStatusProc() - Set the status callback function ---------------------}
  3053.  
  3054. // ICMessage is not supported on NT
  3055.  
  3056. function    ICSetStatusProc(
  3057.     hic         : HIC;
  3058.     dwFlags     : DWORD;
  3059.     lParam      : DWORD;
  3060.     fpfnStatus  : TICStatusProc
  3061.     ): DWORD; stdcall;
  3062. var
  3063.     ic : TICSETSTATUSPROC;
  3064. begin
  3065.     ic.dwFlags  := dwFlags;
  3066.     ic.lParam   := lParam;
  3067.     ic.Status   := fpfnStatus;
  3068.  
  3069.     // note that ICM swaps round the length and pointer
  3070.     // length in lparam2, pointer in lparam1
  3071.     Result      := ICSendMessage(hic, ICM_SET_STATUS_PROC, DWORD(@ic), sizeof(ic));
  3072. end;
  3073.  
  3074. {== Helper routines for DrawDib and MCIAVI... ================================}
  3075.  
  3076. function    ICDecompressOpen(fccType, fccHandler: DWORD; lpbiIn, lpbiOut: PBITMAPINFOHEADER): HIC;
  3077. begin
  3078.     Result := ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, ICMODE_DECOMPRESS);
  3079. end;
  3080.  
  3081. function    ICDrawOpen(fccType, fccHandler: DWORD; lpbiIn: PBITMAPINFOHEADER): HIC;
  3082. begin
  3083.     Result := ICLocate(fccType, fccHandler, lpbiIn, nil, ICMODE_DRAW);
  3084. end;
  3085.  
  3086. {-- DrawDibUpdate() - redraw last image (may only be valid with DDF_BUFFER) --}
  3087.  
  3088. function    DrawDibUpdate(hdd: HDRAWDIB; hdc: HDC; x, y: int): BOOL;
  3089. begin
  3090.     Result  := DrawDibDraw(hdd, hdc, x, y, 0, 0, nil, nil, 0, 0, 0, 0, DDF_UPDATE);
  3091. end;
  3092.  
  3093. {== Useful macros ============================================================}
  3094.  
  3095. {-- Macro to get stream number out of a FOURCC ckid --------------------------}
  3096.  
  3097. function    FromHex(n: BYTE): BYTE;
  3098. begin
  3099.     if n >= Ord('A') then
  3100.         Result := Ord(n) + 10 - Ord('A')
  3101.     else
  3102.         Result := Ord(n) - Ord('0');
  3103. end;
  3104.  
  3105. function    StreamFromFOURCC(fcc: DWORD): BYTE;
  3106. begin
  3107.     Result :=  (FromHex(Lo(LoWord(fcc))) shl 4) + FromHex(Hi(LoWord(fcc)));
  3108. end;
  3109.  
  3110. {-- Macro to get TWOCC chunk type out of a FOURCC ckid -----------------------}
  3111.  
  3112. function    TWOCCFromFOURCC(fcc: DWORD): WORD;
  3113. begin
  3114.     Result := HiWord(fcc);
  3115. end;
  3116.  
  3117. {-- Macro to make a ckid for a chunk out of a TWOCC and a stream num (0-255) -}
  3118.  
  3119. function    ToHex(n: BYTE): BYTE;
  3120. begin
  3121.     if n > 9 then
  3122.         Result := n - 10 + Ord('A')
  3123.     else
  3124.         Result := n + Ord('0');
  3125. end;
  3126.  
  3127. function    MAKEAVICKID(tcc: WORD; stream: BYTE): DWORD;
  3128. begin
  3129.     Result := MakeLONG((ToHex(stream and $0F) shl 8) or ToHex((stream and $F0) shr 4),tcc);
  3130. end;
  3131.  
  3132. {-- Helper macros ------------------------------------------------------------}
  3133.  
  3134. function    AVIStreamSampleToSample(pavi1, pavi2: PAVISTREAM; l: DWORD): DWORD;
  3135. begin
  3136.     Result  := AVIStreamTimeToSample(pavi1,AVIStreamSampleToTime(pavi2, l));
  3137. end;
  3138.  
  3139. function    AVIStreamNextSample(pavi: PAVISTREAM; l: DWORD): DWORD;
  3140. begin
  3141.     Result  := AVIStreamFindSample(pavi,l+1,FIND_NEXT or FIND_ANY);
  3142. end;
  3143.  
  3144. function    AVIStreamPrevSample(pavi: PAVISTREAM; l: DWORD): DWORD;
  3145. begin
  3146.     Result  := AVIStreamFindSample(pavi,l-1,FIND_PREV or FIND_ANY);
  3147. end;
  3148.  
  3149. function    AVIStreamNearestSample(pavi: PAVISTREAM; l: DWORD): DWORD;
  3150. begin
  3151.     Result  := AVIStreamFindSample(pavi,l,FIND_PREV or FIND_ANY);
  3152. end;
  3153.  
  3154. function    AVIStreamNextKeyFrame(pavi: PAVISTREAM; l: DWORD): DWORD;
  3155. begin
  3156.     Result  := AVIStreamFindSample(pavi,l+1,FIND_NEXT or FIND_KEY);
  3157. end;
  3158.  
  3159. function    AVIStreamPrevKeyFrame(pavi: PAVISTREAM; l: DWORD): DWORD;
  3160. begin
  3161.     Result  := AVIStreamFindSample(pavi,l-1,FIND_PREV or FIND_KEY);
  3162. end;
  3163.  
  3164. function    AVIStreamNearestKeyFrame(pavi: PAVISTREAM; l: DWORD): DWORD;
  3165. begin
  3166.     Result  := AVIStreamFindSample(pavi,l,FIND_PREV or FIND_KEY)
  3167. end;
  3168.  
  3169. function    AVIStreamIsKeyFrame(pavi: PAVISTREAM; l: DWORD): BOOL;
  3170. begin
  3171.     Result  := AVIStreamNearestKeyFrame(pavi,l) = l;
  3172. end;
  3173.  
  3174. function    AVIStreamPrevSampleTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  3175. begin
  3176.     Result  := AVIStreamSampleToTime(pavi, AVIStreamPrevSample(pavi,AVIStreamTimeToSample(pavi,t)));
  3177. end;
  3178.  
  3179. function    AVIStreamNextSampleTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  3180. begin
  3181.     Result  := AVIStreamSampleToTime(pavi, AVIStreamNextSample(pavi,AVIStreamTimeToSample(pavi,t)));
  3182. end;
  3183.  
  3184. function    AVIStreamNearestSampleTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  3185. begin
  3186.     Result  := AVIStreamSampleToTime(pavi, AVIStreamNearestSample(pavi,AVIStreamTimeToSample(pavi,t)));
  3187. end;
  3188.  
  3189. function    AVIStreamNextKeyFrameTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  3190. begin
  3191.     Result  := AVIStreamSampleToTime(pavi, AVIStreamNextKeyFrame(pavi,AVIStreamTimeToSample(pavi, t)));
  3192. end;
  3193.  
  3194. function    AVIStreamPrevKeyFrameTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  3195. begin
  3196.     Result  := AVIStreamSampleToTime(pavi, AVIStreamPrevKeyFrame(pavi,AVIStreamTimeToSample(pavi, t)));
  3197. end;
  3198.  
  3199. function    AVIStreamNearestKeyFrameTime(pavi: PAVISTREAM; t: DWORD): DWORD;
  3200. begin
  3201.     Result  := AVIStreamSampleToTime(pavi, AVIStreamNearestKeyFrame(pavi,AVIStreamTimeToSample(pavi, t)));
  3202. end;
  3203.  
  3204. function    AVIStreamStartTime(pavi: PAVISTREAM): DWORD;
  3205. begin
  3206.     Result  := AVIStreamSampleToTime(pavi, AVIStreamStart(pavi));
  3207. end;
  3208.  
  3209. function    AVIStreamLengthTime(pavi: PAVISTREAM): DWORD;
  3210. begin
  3211.     Result  := AVIStreamSampleToTime(pavi, AVIStreamLength(pavi));
  3212. end;
  3213.  
  3214. function    AVIStreamEnd(pavi: PAVISTREAM): DWORD;
  3215. begin
  3216.     Result  := AVIStreamStart(pavi) + AVIStreamLength(pavi);
  3217. end;
  3218.  
  3219. function    AVIStreamEndTime(pavi: PAVISTREAM): DWORD;
  3220. begin
  3221.     Result  := AVIStreamSampleToTime(pavi, AVIStreamEnd(pavi));
  3222. end;
  3223.  
  3224. function    AVIStreamSampleSize(pavi: PAVISTREAM; lPos: DWORD; plSize: PDWORD): DWORD;
  3225. begin
  3226.     Result  := AVIStreamRead(pavi,lPos,1,nil,0,plSize,nil);
  3227. end;
  3228.  
  3229. function    AVIStreamFormatSize(pavi: PAVISTREAM; lPos: DWORD; plSize: PDWORD): HResult;
  3230. begin
  3231.     Result  := AVIStreamReadFormat(pavi,lPos,nil,plSize);
  3232. end;
  3233.  
  3234. function    AVIStreamDataSize(pavi: PAVISTREAM; fcc: DWORD; plSize: PDWORD): HResult;
  3235. begin
  3236.     Result  := AVIStreamReadData(pavi,fcc,nil,plSize)
  3237. end;
  3238.  
  3239. {== MCIWnd ===================================================================}
  3240.  
  3241. function    MCIWndSM(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): DWORD;
  3242. begin
  3243.     Result := SendMessage(hWnd, Msg, wParam, lParam);
  3244. end;
  3245.  
  3246. {-- Can macros ---------------------------------------------------------------}
  3247.  
  3248. function    MCIWndCanPlay(hwnd: HWND): BOOL;
  3249. begin
  3250.     Result  := MCIWndSM(hwnd,MCIWNDM_CAN_PLAY,0,0) <> 0;
  3251. end;
  3252.  
  3253. function    MCIWndCanRecord(hwnd: HWND): BOOL;
  3254. begin
  3255.     Result  := MCIWndSM(hwnd,MCIWNDM_CAN_RECORD,0,0) <> 0;
  3256. end;
  3257.  
  3258. function    MCIWndCanSave(hwnd: HWND): BOOL;
  3259. begin
  3260.     Result  := MCIWndSM(hwnd,MCIWNDM_CAN_SAVE,0,0) <> 0;
  3261. end;
  3262.  
  3263. function    MCIWndCanWindow(hwnd: HWND): BOOL;
  3264. begin
  3265.     Result  := MCIWndSM(hwnd,MCIWNDM_CAN_WINDOW,0,0) <> 0;
  3266. end;
  3267.  
  3268. function    MCIWndCanEject(hwnd: HWND): BOOL;
  3269. begin
  3270.     Result  := MCIWndSM(hwnd,MCIWNDM_CAN_EJECT,0,0) <> 0;
  3271. end;
  3272.  
  3273. function    MCIWndCanConfig(hwnd: HWND): BOOL;
  3274. begin
  3275.     Result  := MCIWndSM(hwnd,MCIWNDM_CAN_CONFIG,0,0) <> 0;
  3276. end;
  3277.  
  3278. function    MCIWndPaletteKick(hwnd: HWND): BOOL;
  3279. begin
  3280.     Result  := MCIWndSM(hwnd,MCIWNDM_PALETTEKICK,0,0) <> 0;
  3281. end;
  3282.  
  3283. function    MCIWndSave(hwnd: HWND; szFile: LPCSTR): DWORD;
  3284. begin
  3285.     Result  := MCIWndSM(hwnd, MCI_SAVE, 0, LPARAM(szFile));
  3286. end;
  3287.  
  3288. function    MCIWndSaveDialog(hwnd: HWND): DWORD;
  3289. begin
  3290.     Result  := MCIWndSave(hwnd, LPCSTR(-1));
  3291. end;
  3292.  
  3293. // If you dont give a device it will use the current device....
  3294.  
  3295. function    MCIWndNew(hwnd: HWND; lp: PVOID): DWORD;
  3296. begin
  3297.     Result  := MCIWndSM(hwnd, MCIWNDM_NEW, 0, LPARAM(lp));
  3298. end;
  3299.  
  3300. function    MCIWndRecord(hwnd: HWND): DWORD;
  3301. begin
  3302.     Result  := MCIWndSM(hwnd, MCI_RECORD, 0, 0);
  3303. end;
  3304.  
  3305. function    MCIWndOpen(hwnd: HWND; sz: LPCSTR; f: BOOL): DWORD;
  3306. begin
  3307.     Result  := MCIWndSM(hwnd, MCIWNDM_OPEN, WPARAM(f), LPARAM(sz));
  3308. end;
  3309.  
  3310. function    MCIWndOpenDialog(hwnd: HWND): DWORD;
  3311. begin
  3312.     Result  := MCIWndOpen(hwnd, LPCSTR(-1), False);
  3313. end;
  3314.  
  3315. function    MCIWndClose(hwnd: HWND): DWORD;
  3316. begin
  3317.     Result  := MCIWndSM(hwnd, MCI_CLOSE, 0, 0);
  3318. end;
  3319.  
  3320. function    MCIWndPlay(hwnd: HWND): DWORD;
  3321. begin
  3322.     Result  := MCIWndSM(hwnd, MCI_PLAY, 0, 0);
  3323. end;
  3324.  
  3325. function    MCIWndStop(hwnd: HWND): DWORD;
  3326. begin
  3327.     Result  := MCIWndSM(hwnd, MCI_STOP, 0, 0);
  3328. end;
  3329.  
  3330. function    MCIWndPause(hwnd: HWND): DWORD;
  3331. begin
  3332.     Result  := MCIWndSM(hwnd, MCI_PAUSE, 0, 0);
  3333. end;
  3334.  
  3335. function    MCIWndResume(hwnd: HWND): DWORD;
  3336. begin
  3337.     Result  := MCIWndSM(hwnd, MCI_RESUME, 0, 0);
  3338. end;
  3339.  
  3340. function    MCIWndSeek(hwnd: HWND; lPos: DWORD): DWORD;
  3341. begin
  3342.     Result  := MCIWndSM(hwnd, MCI_SEEK, 0, lPos);
  3343. end;
  3344.  
  3345. function    MCIWndEject(hwnd: HWND): DWORD;
  3346. begin
  3347.     Result  := MCIWndSM(hwnd, MCIWNDM_EJECT, 0, 0);
  3348. end;
  3349.  
  3350. function    MCIWndHome(hwnd: HWND): DWORD;
  3351. begin
  3352.     Result  := MCIWndSeek(hwnd, MCIWND_START);
  3353. end;
  3354.  
  3355. function    MCIWndEnd(hwnd: HWND): DWORD;
  3356. begin
  3357.     Result  := MCIWndSeek(hwnd, MCIWND_END);
  3358. end;
  3359.  
  3360. function    MCIWndGetSource(hwnd: HWND; prc: PRECT): DWORD;
  3361. begin
  3362.     Result  := MCIWndSM(hwnd, MCIWNDM_GET_SOURCE, 0, LPARAM(prc));
  3363. end;
  3364.  
  3365. function    MCIWndPutSource(hwnd: HWND; prc: PRECT): DWORD;
  3366. begin
  3367.     Result  := MCIWndSM(hwnd, MCIWNDM_PUT_SOURCE, 0, LPARAM(prc));
  3368. end;
  3369.  
  3370. function    MCIWndGetDest(hwnd: HWND; prc: PRECT): DWORD;
  3371. begin
  3372.     Result  := MCIWndSM(hwnd, MCIWNDM_GET_DEST, 0, LPARAM(prc));
  3373. end;
  3374.  
  3375. function    MCIWndPutDest(hwnd: HWND; prc: PRECT): DWORD;
  3376. begin
  3377.     Result  := MCIWndSM(hwnd, MCIWNDM_PUT_DEST, 0, LPARAM(prc));
  3378. end;
  3379.  
  3380. function    MCIWndPlayReverse(hwnd: HWND): DWORD;
  3381. begin
  3382.     Result  := MCIWndSM(hwnd, MCIWNDM_PLAYREVERSE, 0, 0);
  3383. end;
  3384.  
  3385. function    MCIWndPlayFrom(hwnd: HWND; lPos: DWORD): DWORD;
  3386. begin
  3387.     Result  := MCIWndSM(hwnd, MCIWNDM_PLAYFROM, 0, lPos);
  3388. end;
  3389.  
  3390. function    MCIWndPlayTo(hwnd: HWND; lPos: DWORD): DWORD;
  3391. begin
  3392.     Result  := MCIWndSM(hwnd, MCIWNDM_PLAYTO, 0, lPos);
  3393. end;
  3394.  
  3395. function    MCIWndPlayFromTo(hwnd: HWND; lStart, lEnd: DWORD): DWORD;
  3396. begin
  3397.     MCIWndSeek(hwnd, lStart);
  3398.     Result  := MCIWndPlayTo(hwnd, lEnd);
  3399. end;
  3400.  
  3401. function    MCIWndGetDeviceID(hwnd: HWND): UINT;
  3402. begin
  3403.     Result  := MCIWndSM(hwnd, MCIWNDM_GETDEVICEID, 0, 0);
  3404. end;
  3405.  
  3406. function    MCIWndGetAlias(hwnd: HWND): UINT;
  3407. begin
  3408.     Result  := MCIWndSM(hwnd, MCIWNDM_GETALIAS, 0, 0);
  3409. end;
  3410.  
  3411. function    MCIWndGetMode(hwnd: HWND; lp: LPCSTR; len: UINT): DWORD;
  3412. begin
  3413.     Result  := MCIWndSM(hwnd, MCIWNDM_GETMODE, len, LPARAM(lp));
  3414. end;
  3415.  
  3416. function    MCIWndGetPosition(hwnd: HWND): DWORD;
  3417. begin
  3418.     Result  := MCIWndSM(hwnd, MCIWNDM_GETPOSITION, 0, 0);
  3419. end;
  3420.  
  3421. function    MCIWndGetPositionString(hwnd: HWND; lp: LPCSTR; len: UINT): DWORD;
  3422. begin
  3423.     Result  := MCIWndSM(hwnd, MCIWNDM_GETPOSITION, len, LPARAM(lp));
  3424. end;
  3425.  
  3426. function    MCIWndGetStart(hwnd: HWND): DWORD;
  3427. begin
  3428.     Result  := MCIWndSM(hwnd, MCIWNDM_GETSTART, 0, 0);
  3429. end;
  3430.  
  3431. function    MCIWndGetLength(hwnd: HWND): DWORD;
  3432. begin
  3433.     Result  := MCIWndSM(hwnd, MCIWNDM_GETLENGTH, 0, 0);
  3434. end;
  3435.  
  3436. function    MCIWndGetEnd(hwnd: HWND): DWORD;
  3437. begin
  3438.     Result  := MCIWndSM(hwnd, MCIWNDM_GETEND, 0, 0);
  3439. end;
  3440.  
  3441. function    MCIWndStep(hwnd: HWND; n: DWORD): DWORD;
  3442. begin
  3443.     Result  := MCIWndSM(hwnd, MCI_STEP, 0, n);
  3444. end;
  3445.  
  3446. procedure   MCIWndDestroy(hwnd: HWND);
  3447. begin
  3448.     MCIWndSM(hwnd, WM_CLOSE, 0, 0);
  3449. end;
  3450.  
  3451. procedure   MCIWndSetZoom(hwnd: HWND; iZoom: UINT);
  3452. begin
  3453.     MCIWndSM(hwnd, MCIWNDM_SETZOOM, 0, iZoom);
  3454. end;
  3455.  
  3456. function    MCIWndGetZoom(hwnd: HWND): UINT;
  3457. begin
  3458.     Result  := MCIWndSM(hwnd, MCIWNDM_GETZOOM, 0, 0);
  3459. end;
  3460.  
  3461. function    MCIWndSetVolume(hwnd: HWND; iVol: UINT): DWORD;
  3462. begin
  3463.     Result  := MCIWndSM(hwnd, MCIWNDM_SETVOLUME, 0, iVol);
  3464. end;
  3465.  
  3466. function    MCIWndGetVolume(hwnd: HWND): DWORD;
  3467. begin
  3468.     Result  := MCIWndSM(hwnd, MCIWNDM_GETVOLUME, 0, 0);
  3469. end;
  3470.  
  3471. function    MCIWndSetSpeed(hwnd: HWND; iSpeed: UINT): DWORD;
  3472. begin
  3473.     Result  := MCIWndSM(hwnd, MCIWNDM_SETSPEED, 0, iSpeed);
  3474. end;
  3475.  
  3476. function    MCIWndGetSpeed(hwnd: HWND): DWORD;
  3477. begin
  3478.     Result  := MCIWndSM(hwnd, MCIWNDM_GETSPEED, 0, 0);
  3479. end;
  3480.  
  3481. function    MCIWndSetTimeFormat(hwnd: HWND; lp: LPCSTR): DWORD;
  3482. begin
  3483.     Result  := MCIWndSM(hwnd, MCIWNDM_SETTIMEFORMAT, 0, LPARAM(lp));
  3484. end;
  3485.  
  3486. function    MCIWndGetTimeFormat(hwnd: HWND; lp: LPCSTR; len: UINT): DWORD;
  3487. begin
  3488.     Result  := MCIWndSM(hwnd, MCIWNDM_GETTIMEFORMAT, len, LPARAM(lp));
  3489. end;
  3490.  
  3491. procedure   MCIWndValidateMedia(hwnd: HWND);
  3492. begin
  3493.     MCIWndSM(hwnd, MCIWNDM_VALIDATEMEDIA, 0, 0);
  3494. end;
  3495.  
  3496. procedure   MCIWndSetRepeat(hwnd: HWND; f: BOOL);
  3497. begin
  3498.     MCIWndSM(hwnd, MCIWNDM_SETREPEAT, 0, LPARAM(f));
  3499. end;
  3500.  
  3501. function    MCIWndGetRepeat(hwnd: HWND): BOOL;
  3502. begin
  3503.     Result  := MCIWndSM(hwnd, MCIWNDM_GETREPEAT, 0, 0) <> 0;
  3504. end;
  3505.  
  3506. function    MCIWndUseFrames(hwnd: HWND): DWORD;
  3507. begin
  3508.     Result  := MCIWndSetTimeFormat(hwnd, 'frames');
  3509. end;
  3510.  
  3511. function    MCIWndUseTime(hwnd: HWND): DWORD;
  3512. begin
  3513.     Result  := MCIWndSetTimeFormat(hwnd, 'ms');
  3514. end;
  3515.  
  3516. procedure   MCIWndSetActiveTimer(hwnd: HWND; active: UINT);
  3517. begin
  3518.     MCIWndSM(hwnd, MCIWNDM_SETACTIVETIMER, active, 0);
  3519. end;
  3520.  
  3521. procedure   MCIWndSetInactiveTimer(hwnd: HWND; inactive: UINT);
  3522. begin
  3523.     MCIWndSM(hwnd, MCIWNDM_SETINACTIVETIMER, inactive, 0);
  3524. end;
  3525.  
  3526. procedure   MCIWndSetTimers(hwnd: HWND; active, inactive: UINT);
  3527. begin
  3528.     MCIWndSM(hwnd, MCIWNDM_SETTIMERS, active, inactive);
  3529. end;
  3530.  
  3531. function    MCIWndGetActiveTimer(hwnd: HWND): UINT;
  3532. begin
  3533.     Result  := MCIWndSM(hwnd, MCIWNDM_GETACTIVETIMER, 0, 0);
  3534. end;
  3535.  
  3536. function    MCIWndGetInactiveTimer(hwnd: HWND): UINT;
  3537. begin
  3538.     Result  := MCIWndSM(hwnd, MCIWNDM_GETINACTIVETIMER, 0, 0);
  3539. end;
  3540.  
  3541. function    MCIWndRealize(hwnd: HWND; fBkgnd: BOOL): DWORD;
  3542. begin
  3543.     Result  := MCIWndSM(hwnd, MCIWNDM_REALIZE, WPARAM(fBkgnd), 0);
  3544. end;
  3545.  
  3546. function    MCIWndSendString(hwnd: HWND; sz: LPCSTR): DWORD;
  3547. begin
  3548.     Result  := MCIWndSM(hwnd, MCIWNDM_SENDSTRING, 0, LPARAM(sz));
  3549. end;
  3550.  
  3551. function    MCIWndReturnString(hwnd: HWND; lp: LPSTR; len: UINT): DWORD;
  3552. begin
  3553.     Result  := MCIWndSM(hwnd, MCIWNDM_RETURNSTRING, len, LPARAM(lp));
  3554. end;
  3555.  
  3556. function    MCIWndGetError(hwnd: HWND; lp: LPSTR; len: UINT): DWORD;
  3557. begin
  3558.     Result  := MCIWndSM(hwnd, MCIWNDM_GETERROR, len, LPARAM(lp));
  3559. end;
  3560.  
  3561. function    MCIWndGetPalette(hwnd: HWND): HPALETTE;
  3562. begin
  3563.     Result  := MCIWndSM(hwnd, MCIWNDM_GETPALETTE, 0, 0);
  3564. end;
  3565.  
  3566. function    MCIWndSetPalette(hwnd: HWND; hpal: HPALETTE): DWORD;
  3567. begin
  3568.     Result  := MCIWndSM(hwnd, MCIWNDM_SETPALETTE, hpal, 0);
  3569. end;
  3570.  
  3571. function    MCIWndGetFileName(hwnd: HWND; lp: LPCSTR; len: UINT): DWORD;
  3572. begin
  3573.     Result  := MCIWndSM(hwnd, MCIWNDM_GETFILENAME, len, LPARAM(lp));
  3574. end;
  3575.  
  3576. function    MCIWndGetDevice(hwnd: HWND; lp: LPCSTR; len: UINT): DWORD;
  3577. begin
  3578.     Result  := MCIWndSM(hwnd, MCIWNDM_GETDEVICE, len, LPARAM(lp));
  3579. end;
  3580.  
  3581. function    MCIWndGetStyles(hwnd: HWND): UINT;
  3582. begin
  3583.     Result  := MCIWndSM(hwnd, MCIWNDM_GETSTYLES, 0, 0);
  3584. end;
  3585.  
  3586. function    MCIWndChangeStyles(hwnd: HWND; mask: UINT; value: DWORD): DWORD;
  3587. begin
  3588.     Result  := MCIWndSM(hwnd, MCIWNDM_CHANGESTYLES, mask, value);
  3589. end;
  3590.  
  3591. function    MCIWndOpenInterface(hwnd: HWND; pUnk: PUNKNOWN): DWORD;
  3592. begin
  3593.     Result  := MCIWndSM(hwnd, MCIWNDM_OPENINTERFACE, 0, LPARAM(pUnk));
  3594. end;
  3595.  
  3596. function    MCIWndSetOwner(hwnd: HWND; hwndP: HWND): DWORD;
  3597. begin
  3598.     Result  := MCIWndSM(hwnd, MCIWNDM_SETOWNER, hwndP, 0);
  3599. end;
  3600.  
  3601. {== AVICAP - Window class for AVI capture ====================================}
  3602.  
  3603. function    AVICapSM(hwnd: HWND; m: UINT; w: WPARAM; l: LPARAM): DWORD;
  3604. begin
  3605.     if IsWindow(hwnd) then
  3606.         Result := SendMessage(hwnd,m,w,l)
  3607.     else
  3608.         Result := 0;
  3609. end;
  3610.  
  3611. {-- Message crackers for above -----------------------------------------------}
  3612.  
  3613. function    capSetCallbackOnError(hwnd: HWND; fpProc: TCAPERRORCALLBACK): BOOL;
  3614. begin
  3615.     Result  := AVICapSM(hwnd, WM_CAP_SET_CALLBACK_ERROR, 0, LPARAM(@fpProc)) <> 0;
  3616. end;
  3617.  
  3618. function    capSetCallbackOnStatus(hwnd: HWND; fpProc: TCAPSTATUSCALLBACK): BOOL;
  3619. begin
  3620.     Result  := AVICapSM(hwnd, WM_CAP_SET_CALLBACK_STATUS, 0, LPARAM(@fpProc)) <> 0;
  3621. end;
  3622.  
  3623. function    capSetCallbackOnYield(hwnd: HWND; fpProc: TCAPYIELDCALLBACK): BOOL;
  3624. begin
  3625.     Result  := AVICapSM(hwnd, WM_CAP_SET_CALLBACK_YIELD, 0, LPARAM(@fpProc)) <> 0;
  3626. end;
  3627.  
  3628. function    capSetCallbackOnFrame(hwnd: HWND; fpProc: TCAPVIDEOCALLBACK): BOOL;
  3629. begin
  3630.     Result  := AVICapSM(hwnd, WM_CAP_SET_CALLBACK_FRAME, 0, LPARAM(@fpProc)) <> 0;
  3631. end;
  3632.  
  3633. function    capSetCallbackOnVideoStream(hwnd: HWND; fpProc: TCAPVIDEOCALLBACK): BOOL;
  3634. begin
  3635.     Result  := AVICapSM(hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, LPARAM(@fpProc)) <> 0;
  3636. end;
  3637.  
  3638. function    capSetCallbackOnWaveStream(hwnd: HWND; fpProc: TCAPWAVECALLBACK): BOOL;
  3639. begin
  3640.     Result  := AVICapSM(hwnd, WM_CAP_SET_CALLBACK_WAVESTREAM, 0, LPARAM(@fpProc)) <> 0;
  3641. end;
  3642.  
  3643. function    capSetCallbackOnCapControl(hwnd: HWND; fpProc: TCAPCONTROLCALLBACK): BOOL;
  3644. begin
  3645.     Result  := AVICapSM(hwnd, WM_CAP_SET_CALLBACK_CAPCONTROL, 0, LPARAM(@fpProc)) <> 0;
  3646. end;
  3647.  
  3648. function    capSetUserData(hwnd: HWND; lUser: DWORD): BOOL;
  3649. begin
  3650.     Result  := AVICapSM(hwnd, WM_CAP_SET_USER_DATA, 0, lUser) <> 0;
  3651. end;
  3652.  
  3653. function    capGetUserData(hwnd: HWND): DWORD;
  3654. begin
  3655.     Result  := AVICapSM(hwnd, WM_CAP_GET_USER_DATA, 0, 0);
  3656. end;
  3657.  
  3658. function    capDriverConnect(hwnd: HWND; i: INT): BOOL;
  3659. begin
  3660.     Result  := AVICapSM(hwnd, WM_CAP_DRIVER_CONNECT, i, 0) <> 0;
  3661. end;
  3662.  
  3663. function    capDriverDisconnect(hwnd: HWND): BOOL;
  3664. begin
  3665.     Result  := AVICapSM(hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0) <> 0;
  3666. end;
  3667.  
  3668. function    capDriverGetName(hwnd: HWND; szName: LPSTR; wSize: WORD): BOOL;
  3669. begin
  3670.     Result  := AVICapSM(hwnd, WM_CAP_DRIVER_GET_NAME, wSize, LPARAM(szName)) <> 0;
  3671. end;
  3672.  
  3673. function    capDriverGetVersion(hwnd: HWND; szVer: LPSTR; wSize: WORD): BOOL;
  3674. begin
  3675.     Result  := AVICapSM(hwnd, WM_CAP_DRIVER_GET_VERSION, wSize, LPARAM(szVer)) <> 0;
  3676. end;
  3677.  
  3678. function    capDriverGetCaps(hwnd: HWND; s: PCAPDRIVERCAPS; wSize: WORD): BOOL;
  3679. begin
  3680.     Result  := AVICapSM(hwnd, WM_CAP_DRIVER_GET_CAPS, wSize, LPARAM(s)) <> 0;
  3681. end;
  3682.  
  3683. function    capFileSetCaptureFile(hwnd: HWND; szName: LPCSTR): BOOL;
  3684. begin
  3685.     Result  := AVICapSM(hwnd, WM_CAP_FILE_SET_CAPTURE_FILE, 0, LPARAM(szName)) <> 0;
  3686. end;
  3687.  
  3688. function    capFileGetCaptureFile(hwnd: HWND; szName: LPSTR; wSize: WORD): BOOL;
  3689. begin
  3690.     Result  := AVICapSM(hwnd, WM_CAP_FILE_GET_CAPTURE_FILE, wSize, LPARAM(szName)) <> 0;
  3691. end;
  3692.  
  3693. function    capFileAlloc(hwnd: HWND; dwSize: DWORD): BOOL;
  3694. begin
  3695.     Result  := AVICapSM(hwnd, WM_CAP_FILE_ALLOCATE, 0, dwSize) <> 0;
  3696. end;
  3697.  
  3698. function    capFileSaveAs(hwnd: HWND; szName: LPCSTR): BOOL;
  3699. begin
  3700.     Result  := AVICapSM(hwnd, WM_CAP_FILE_SAVEAS, 0, LPARAM(szName)) <> 0;
  3701. end;
  3702.  
  3703. function    capFileSetInfoChunk(hwnd: HWND; lpInfoChunk: PCAPINFOCHUNK): BOOL;
  3704. begin
  3705.     Result  := AVICapSM(hwnd, WM_CAP_FILE_SET_INFOCHUNK, 0, LPARAM(lpInfoChunk)) <> 0;
  3706. end;
  3707.  
  3708. function    capFileSaveDIB(hwnd: HWND; szName: LPCSTR): BOOL;
  3709. begin
  3710.     Result  := AVICapSM(hwnd, WM_CAP_FILE_SAVEDIB, 0, LPARAM(szName)) <> 0;
  3711. end;
  3712.  
  3713. function    capEditCopy(hwnd: HWND): BOOL;
  3714. begin
  3715.     Result  := AVICapSM(hwnd, WM_CAP_EDIT_COPY, 0, 0) <> 0;
  3716. end;
  3717.  
  3718. function    capSetAudioFormat(hwnd: HWND; s: PWAVEFORMATEX; wSize: WORD): BOOL;
  3719. begin
  3720.     Result  := AVICapSM(hwnd, WM_CAP_SET_AUDIOFORMAT, wSize, LPARAM(s)) <> 0;
  3721. end;
  3722.  
  3723. function    capGetAudioFormat(hwnd: HWND; s: PWAVEFORMATEX; wSize: WORD): DWORD;
  3724. begin
  3725.     Result  := AVICapSM(hwnd, WM_CAP_GET_AUDIOFORMAT, wSize, LPARAM(s));
  3726. end;
  3727.  
  3728. function    capGetAudioFormatSize(hwnd: HWND): DWORD;
  3729. begin
  3730.     Result  := AVICapSM(hwnd, WM_CAP_GET_AUDIOFORMAT, 0, 0);
  3731. end;
  3732.  
  3733. function    capDlgVideoFormat(hwnd: HWND): BOOL;
  3734. begin
  3735.     Result  := AVICapSM(hwnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0) <> 0;
  3736. end;
  3737.  
  3738. function    capDlgVideoSource(hwnd: HWND): BOOL;
  3739. begin
  3740.     Result  := AVICapSM(hwnd, WM_CAP_DLG_VIDEOSOURCE, 0, 0) <> 0;
  3741. end;
  3742.  
  3743. function    capDlgVideoDisplay(hwnd: HWND): BOOL;
  3744. begin
  3745.     Result  := AVICapSM(hwnd, WM_CAP_DLG_VIDEODISPLAY, 0, 0) <> 0;
  3746. end;
  3747.  
  3748. function    capDlgVideoCompression(hwnd: HWND): BOOL;
  3749. begin
  3750.     Result  := AVICapSM(hwnd, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0) <> 0;
  3751. end;
  3752.  
  3753. function    capGetVideoFormat(hwnd: HWND; s: PVOID; wSize: WORD): DWORD;
  3754. begin
  3755.     Result  := AVICapSM(hwnd, WM_CAP_GET_VIDEOFORMAT, wSize, LPARAM(s));
  3756. end;
  3757.  
  3758. function    capGetVideoFormatSize(hwnd: HWND): DWORD;
  3759. begin
  3760.     Result  := AVICapSM(hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
  3761. end;
  3762.  
  3763. function    capSetVideoFormat(hwnd: HWND; s: PVOID; wSize: WORD): BOOL;
  3764. begin
  3765.     Result  := AVICapSM(hwnd, WM_CAP_SET_VIDEOFORMAT, wSize, LPARAM(s)) <> 0;
  3766. end;
  3767.  
  3768. function    capPreview(hwnd: HWND; f: BOOL): BOOL;
  3769. begin
  3770.     Result  := AVICapSM(hwnd, WM_CAP_SET_PREVIEW, WPARAM(f), 0) <> 0;
  3771. end;
  3772.  
  3773. function    capPreviewRate(hwnd: HWND; wMS: WORD): BOOL;
  3774. begin
  3775.     Result  := AVICapSM(hwnd, WM_CAP_SET_PREVIEWRATE, wMS, 0) <> 0;
  3776. end;
  3777.  
  3778. function    capOverlay(hwnd: HWND; f: BOOL): BOOL;
  3779. begin
  3780.     Result  := AVICapSM(hwnd, WM_CAP_SET_OVERLAY, WPARAM(f), 0) <> 0;
  3781. end;
  3782.  
  3783. function    capPreviewScale(hwnd: HWND; f: BOOL): BOOL;
  3784. begin
  3785.     Result  := AVICapSM(hwnd, WM_CAP_SET_SCALE, WPARAM(f), 0) <> 0;
  3786. end;
  3787.  
  3788. function    capGetStatus(hwnd: HWND; s: PCAPSTATUS; wSize: WORD): BOOL;
  3789. begin
  3790.     Result  := AVICapSM(hwnd, WM_CAP_GET_STATUS, wSize, LPARAM(s)) <> 0;
  3791. end;
  3792.  
  3793. function    capSetScrollPos(hwnd: HWND; lpP: PPOINT): BOOL;
  3794. begin
  3795.     Result  := AVICapSM(hwnd, WM_CAP_SET_SCROLL, 0, LPARAM(lpP)) <> 0;
  3796. end;
  3797.  
  3798. function    capGrabFrame(hwnd: HWND): BOOL;
  3799. begin
  3800.     Result  := AVICapSM(hwnd, WM_CAP_GRAB_FRAME, 0, 0) <> 0;
  3801. end;
  3802.  
  3803. function    capGrabFrameNoStop(hwnd: HWND): BOOL;
  3804. begin
  3805.     Result  := AVICapSM(hwnd, WM_CAP_GRAB_FRAME_NOSTOP, 0, 0) <> 0;
  3806. end;
  3807.  
  3808. function    capCaptureSequence(hwnd: HWND): BOOL;
  3809. begin
  3810.     Result  := AVICapSM(hwnd, WM_CAP_SEQUENCE, 0, 0) <> 0;
  3811. end;
  3812.  
  3813. function    capCaptureSequenceNoFile(hwnd: HWND): BOOL;
  3814. begin
  3815.     Result  := AVICapSM(hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0) <> 0;
  3816. end;
  3817.  
  3818. function    capCaptureStop(hwnd: HWND): BOOL;
  3819. begin
  3820.     Result  := AVICapSM(hwnd, WM_CAP_STOP, 0, 0) <> 0;
  3821. end;
  3822.  
  3823. function    capCaptureAbort(hwnd: HWND): BOOL;
  3824. begin
  3825.     Result  := AVICapSM(hwnd, WM_CAP_ABORT, 0, 0) <> 0;
  3826. end;
  3827.  
  3828. function    capCaptureSingleFrameOpen(hwnd: HWND): BOOL;
  3829. begin
  3830.     Result  := AVICapSM(hwnd, WM_CAP_SINGLE_FRAME_OPEN, 0, 0) <> 0;
  3831. end;
  3832.  
  3833. function    capCaptureSingleFrameClose(hwnd: HWND): BOOL;
  3834. begin
  3835.     Result  := AVICapSM(hwnd, WM_CAP_SINGLE_FRAME_CLOSE, 0, 0) <> 0;
  3836. end;
  3837.  
  3838. function    capCaptureSingleFrame(hwnd: HWND): BOOL;
  3839. begin
  3840.     Result  := AVICapSM(hwnd, WM_CAP_SINGLE_FRAME, 0, 0) <> 0;
  3841. end;
  3842.  
  3843. function    capCaptureGetSetup(hwnd: HWND; s: PCAPTUREPARMS; wSize: WORD): BOOL;
  3844. begin
  3845.     Result  := AVICapSM(hwnd, WM_CAP_GET_SEQUENCE_SETUP, wSize, LPARAM(s)) <> 0;
  3846. end;
  3847.  
  3848. function    capCaptureSetSetup(hwnd: HWND; s: PCAPTUREPARMS; wSize: WORD): BOOL;
  3849. begin
  3850.     Result  := AVICapSM(hwnd, WM_CAP_SET_SEQUENCE_SETUP, wSize, LPARAM(s)) <> 0;
  3851. end;
  3852.  
  3853. function    capSetMCIDeviceName(hwnd: HWND; szName: LPCSTR): BOOL;
  3854. begin
  3855.     Result  := AVICapSM(hwnd, WM_CAP_SET_MCI_DEVICE, 0, LPARAM(szName)) <> 0;
  3856. end;
  3857.  
  3858. function    capGetMCIDeviceName(hwnd: HWND; szName: LPSTR; wSize: WORD): BOOL;
  3859. begin
  3860.     Result  := AVICapSM(hwnd, WM_CAP_GET_MCI_DEVICE, wSize, LPARAM(szName)) <> 0;
  3861. end;
  3862.  
  3863. function    capPaletteOpen(hwnd: HWND; szName: LPCSTR): BOOL;
  3864. begin
  3865.     Result  := AVICapSM(hwnd, WM_CAP_PAL_OPEN, 0, LPARAM(szName)) <> 0;
  3866. end;
  3867.  
  3868. function    capPaletteSave(hwnd: HWND; szName: LPCSTR): BOOL;
  3869. begin
  3870.     Result  := AVICapSM(hwnd, WM_CAP_PAL_SAVE, 0, LPARAM(szName)) <> 0;
  3871. end;
  3872.  
  3873. function    capPalettePaste(hwnd: HWND): BOOL;
  3874. begin
  3875.     Result  := AVICapSM(hwnd, WM_CAP_PAL_PASTE, 0, 0) <> 0;
  3876. end;
  3877.  
  3878. function    capPaletteAuto(hwnd: HWND; iFrames, iColors: INT): BOOL;
  3879. begin
  3880.     Result  := AVICapSM(hwnd, WM_CAP_PAL_AUTOCREATE, iFrames, iColors) <> 0;
  3881. end;
  3882.  
  3883. function    capPaletteManual(hwnd: HWND; fGrab: BOOL; iColors: INT): BOOL;
  3884. begin
  3885.     Result  := AVICapSM(hwnd, WM_CAP_PAL_MANUALCREATE, WPARAM(fGrab), iColors) <> 0;
  3886. end;
  3887.  
  3888. {== Externals ================================================================}
  3889.  
  3890. const
  3891.     VFWDLL      = 'MSVFW32.DLL';
  3892.     AVIFILDLL   = 'AVIFIL32.DLL';
  3893.     AVICAPDLL   = 'AVICAP32.DLL';
  3894.  
  3895. {-- Returns version of VFW ---------------------------------------------------}
  3896.  
  3897. function    VideoForWindowsVersion: DWord; pascal; external VFWDLL;
  3898.  
  3899. {-- Call these to start stop using VfW from your app -------------------------}
  3900.  
  3901. { TODO: Where are these functions? }
  3902.  
  3903. // function    InitVFW: DWORD; stdcall;
  3904. // function    TermVFW: DWORD; stdcall;
  3905.  
  3906. {-- ICM function declarations ------------------------------------------------}
  3907.  
  3908. function    ICInfo(fccType, fccHandler: DWORD; lpicinfo: PICINFO) : BOOL ; stdcall ; external VFWDLL;
  3909. function    ICInstall(fccType, fccHandler: DWORD; lParam: LPARAM; szDesc: LPSTR; wFlags: UINT) : BOOL ; stdcall ; external VFWDLL;
  3910. function    ICRemove(fccType, fccHandler: DWORD; wFlags: UINT) : BOOL ; stdcall ; external VFWDLL;
  3911. function    ICGetInfo(hic: HIC; picinfo: PICINFO; cb: DWORD) : DWORD ; stdcall ; external VFWDLL;
  3912.  
  3913. function    ICOpen(fccType, fccHandler: DWORD; wMode: UINT) : HIC ; stdcall ; external VFWDLL;
  3914. function    ICOpenFunction(fccType, fccHandler: DWORD; wMode: UINT; lpfnHandler: TFarProc) : HIC ; stdcall ; external VFWDLL;
  3915. function    ICClose(hic: HIC) : DWORD ; stdcall ; external VFWDLL;
  3916.  
  3917. function    ICSendMessage(hic: HIC; msg: UINT; dw1, dw2: DWORD) : DWORD ; stdcall ; external VFWDLL;
  3918.  
  3919. {== Compression functions ====================================================}
  3920.  
  3921. {-- ICCompress() - compress a single frame -----------------------------------}
  3922.  
  3923. function    ICCompress(
  3924.     hic             : HIC;
  3925.     dwFlags         : DWORD;                // flags
  3926.     lpbiOutput      : PBITMAPINFOHEADER;    // output format
  3927.     lpData          : PVOID;                // output data
  3928.     lpbiInput       : PBITMAPINFOHEADER;    // format of frame to compress
  3929.     lpBits          : PVOID;                // frame data to compress
  3930.     lpckid          : PDWORD;               // ckid for data in AVI file
  3931.     lpdwFlags       : PDWORD;               // flags in the AVI index.
  3932.     lFrameNum       : DWORD;                 // frame number of seq.
  3933.     dwFrameSize     : DWORD;                // reqested size in bytes. (if non zero)
  3934.     dwQuality       : DWORD;                // quality within one frame
  3935.     lpbiPrev        : PBITMAPINFOHEADER;    // format of previous frame
  3936.     lpPrev          : PVOID                 // previous frame
  3937.     ) : DWORD; cdecl; external VFWDLL;
  3938.  
  3939. {== Decompression functions ==================================================}
  3940.  
  3941. {-- ICDecompress() - decompress a single frame -------------------------------}
  3942.  
  3943. function    ICDecompress(
  3944.     hic             : HIC;
  3945.     dwFlags         : DWORD;                // flags (from AVI index...)
  3946.     lpbiFormat      : PBITMAPINFOHEADER;    // BITMAPINFO of compressed data
  3947.                                             // biSizeImage has the chunk size
  3948.     lpData          : PVOID;                // data
  3949.     lpbi            : PBITMAPINFOHEADER;    // DIB to decompress to
  3950.     lpBits          : PVOID
  3951.     ): DWORD; cdecl; external VFWDLL;
  3952.  
  3953. {== Drawing functions ========================================================}
  3954.  
  3955. {-- ICDrawBegin() - start decompressing data with fmt directly to screen -----}
  3956.  
  3957. // return zero if the decompressor supports drawing.
  3958.  
  3959. function    ICDrawBegin(
  3960.     hic         : HIC;
  3961.     dwFlags     : DWORD;                // flags
  3962.     hpal        : HPALETTE;             // palette to draw with
  3963.     hwnd        : HWND;                 // window to draw to
  3964.     hdc         : HDC;                  // HDC to draw to
  3965.     xDst        : int;                  // destination rectangle
  3966.     yDst        : int;
  3967.     dxDst       : int;
  3968.     dyDst       : int;
  3969.     lpbi        : PBITMAPINFOHEADER;    // format of frame to draw
  3970.     xSrc        : int;                  // source rectangle
  3971.     ySrc        : int;
  3972.     dxSrc       : int;
  3973.     dySrc       : int;
  3974.     dwRate      : DWORD;                // frames/second = (dwRate/dwScale)
  3975.     dwScale     : DWORD
  3976.     ): DWORD; cdecl; external VFWDLL;
  3977.  
  3978. {-- ICDraw() - decompress data directly to the screen ------------------------}
  3979.  
  3980. function    ICDraw(
  3981.     hic         : HIC;
  3982.     dwFlags     : DWORD;                // flags
  3983.     lpFormat    : PVOID;                // format of frame to decompress
  3984.     lpData      : PVOID;                // frame data to decompress
  3985.     cbData      : DWORD;                // size of data
  3986.     lTime       : DWORD                  // time to draw this frame
  3987.     ): DWORD; cdecl; external VFWDLL;
  3988.  
  3989. {== Helper routines for DrawDib and MCIAVI... ================================}
  3990.  
  3991. function    ICLocate(fccType, fccHandler: DWORD; lpbiIn, lpbiOut: PBITMAPINFOHEADER; wFlags: WORD): HIC; stdcall; external VFWDLL;
  3992. function    ICGetDisplayFormat(hic: HIC; lpbiIn, lpbiOut: PBITMAPINFOHEADER; BitDepth: int; dx, dy: int): HIC; stdcall; external VFWDLL;
  3993.  
  3994. {== Higher level functions ===================================================}
  3995.  
  3996. function    ICImageCompress(
  3997.     hic         : HIC;                  // compressor to use
  3998.     uiFlags     : UINT;                 // flags (none yet)
  3999.     lpbiIn      : PBITMAPINFO;          // format to compress from
  4000.     lpBits      : PVOID;                // data to compress
  4001.     lpbiOut     : PBITMAPINFO;          // compress to this (NULL ==> default)
  4002.     lQuality    : DWORD;                 // quality to use
  4003.     plSize      : PDWORD                 // compress to this size (0=whatever)
  4004.     ): THANDLE; stdcall; external VFWDLL;
  4005.  
  4006. function    ICImageDecompress(
  4007.     hic         : HIC;                  // compressor to use
  4008.     uiFlags     : UINT;                 // flags (none yet)
  4009.     lpbiIn      : PBITMAPINFO;          // format to decompress from
  4010.     lpBits      : PVOID;                // data to decompress
  4011.     lpbiOut     : PBITMAPINFO           // decompress to this (NULL ==> default)
  4012.     ): THANDLE; stdcall; external VFWDLL;
  4013.  
  4014. {-- ICCompressorChoose() - allows user to choose compressor, quality etc... --}
  4015.  
  4016. function    ICCompressorChoose(
  4017.     hwnd        : HWND;                     // parent window for dialog
  4018.     uiFlags     : UINT;                     // flags
  4019.     pvIn        : PVOID;                    // input format (optional)
  4020.     lpData      : PVOID;                    // input data (optional)
  4021.     pc          : PCOMPVARS;                // data about the compressor/dlg
  4022.     lpszTitle   : LPSTR                     // dialog title (optional)
  4023.     ): BOOL; stdcall; external VFWDLL;
  4024.  
  4025. function    ICSeqCompressFrameStart(pc: PCOMPVARS; lpbiIn: PBITMAPINFO): BOOL; stdcall; external VFWDLL;
  4026. procedure   ICSeqCompressFrameEnd(pc: PCOMPVARS); stdcall; external VFWDLL;
  4027.  
  4028. function    ICSeqCompressFrame(
  4029.     pc          : PCOMPVARS;                // set by ICCompressorChoose
  4030.     uiFlags     : UINT;                     // flags
  4031.     lpBits      : PVOID;                    // input DIB bits
  4032.     pfKey       : PBOOL;                    // did it end up being a key frame?
  4033.     plSize      : PDWORD                     // size to compress to/of returned image
  4034.     ): PVOID; stdcall; external VFWDLL;
  4035.  
  4036. procedure   ICCompressorFree(pc: PCOMPVARS); stdcall; external VFWDLL;
  4037.  
  4038. {== DrawDib functions ========================================================}
  4039.  
  4040. {-- DrawDibOpen() ------------------------------------------------------------}
  4041.  
  4042. function    DrawDibOpen: HDRAWDIB; stdcall; external VFWDLL;
  4043.  
  4044. {-- DrawDibClose() -----------------------------------------------------------}
  4045.  
  4046. function    DrawDibClose(hdd: HDRAWDIB): BOOL; stdcall; external VFWDLL;
  4047.  
  4048. {-- DrawDibGetBuffer() -------------------------------------------------------}
  4049.  
  4050. function    DrawDibGetBuffer(hdd: HDRAWDIB; lpbi: PBITMAPINFOHEADER; dwSize: DWORD; dwFlags: DWORD): PVOID; stdcall; external VFWDLL;
  4051.  
  4052. {-- DrawDibGetPalette() - get the palette used for drawing DIBs --------------}
  4053.  
  4054. function    DrawDibGetPalette(hdd: HDRAWDIB): HPALETTE; stdcall; external VFWDLL;
  4055.  
  4056. {-- DrawDibSetPalette() - set the palette used for drawing DIBs --------------}
  4057.  
  4058. function    DrawDibSetPalette(hdd: HDRAWDIB; hpal: HPALETTE): BOOL; stdcall; external VFWDLL;
  4059.  
  4060. {-- DrawDibChangePalette() ---------------------------------------------------}
  4061.  
  4062. function    DrawDibChangePalette(hdd: HDRAWDIB; iStart, iLen: int; lppe: PPALETTEENTRY): BOOL; stdcall; external VFWDLL;
  4063.  
  4064. {-- DrawDibRealize() - realize the palette in a HDD --------------------------}
  4065.  
  4066. function    DrawDibRealize(hdd: HDRAWDIB; hdc: HDC; fBackground: BOOL): UINT; stdcall; external VFWDLL;
  4067.  
  4068. {-- DrawDibStart() - start of streaming playback -----------------------------}
  4069.  
  4070. function    DrawDibStart(hdd: HDRAWDIB; rate: DWORD): BOOL; stdcall; external VFWDLL;
  4071.  
  4072. {-- DrawDibStop() - start of streaming playback ------------------------------}
  4073.  
  4074. function    DrawDibStop(hdd: HDRAWDIB): BOOL; stdcall; external VFWDLL;
  4075.  
  4076. {-- DrawDibBegin() - prepare to draw -----------------------------------------}
  4077.  
  4078. function    DrawDibBegin(
  4079.     hdd         : HDRAWDIB;
  4080.     hdc         : HDC;
  4081.     dxDst       : int;
  4082.     dyDst       : int;
  4083.     lpbi        : PBITMAPINFOHEADER;
  4084.     dxSrc       : int;
  4085.     dySrc       : int;
  4086.     wFlags      : UINT
  4087.     ): BOOL; stdcall; external VFWDLL;
  4088.  
  4089. {-- DrawDibDraw() - actually draw a DIB to the screen ------------------------}
  4090.  
  4091. function    DrawDibDraw(
  4092.     hdd         : HDRAWDIB;
  4093.     hdc         : HDC;
  4094.     xDst        : int;
  4095.     yDst        : int;
  4096.     dxDst       : int;
  4097.     dyDst       : int;
  4098.     lpbi        : PBITMAPINFOHEADER;
  4099.     lpBits      : PVOID;
  4100.     xSrc        : int;
  4101.     ySrc        : int;
  4102.     dxSrc       : int;
  4103.     dySrc       : int;
  4104.     wFlags      : UINT
  4105.     ): BOOL; stdcall; external VFWDLL;
  4106.  
  4107. {-- DrawDibEnd() -------------------------------------------------------------}
  4108.  
  4109. function    DrawDibEnd(hdd: HDRAWDIB): BOOL; stdcall; external VFWDLL;
  4110.  
  4111. {-- DrawDibTime() - for debugging purposes only ------------------------------}
  4112.  
  4113. function    DrawDibTime(hdd: HDRAWDIB; lpddtime: PDRAWDIBTIME): BOOL; stdcall; external VFWDLL;
  4114.  
  4115. {-- Display profiling --------------------------------------------------------}
  4116.  
  4117. function    DrawDibProfileDisplay(lpbi: PBITMAPINFOHEADER): DWORD; stdcall; external VFWDLL;
  4118.  
  4119. {-- Functions ----------------------------------------------------------------}
  4120.  
  4121. procedure   AVIFileInit; stdcall; external AVIFILDLL; // Call this first!
  4122. procedure   AVIFileExit; stdcall; external AVIFILDLL;
  4123.  
  4124. function    AVIFileAddRef(pfile: PAVIFILE): UDWORD; stdcall; external AVIFILDLL;
  4125. function    AVIFileRelease(pfile: PAVIFILE): UDWORD; stdcall; external AVIFILDLL;
  4126.  
  4127. function    AVIFileOpenA(var ppfile: PAVIFILE; szFile: LPCSTR; uMode: UINT; lpHandler: PCLSID): HResult; stdcall; external AVIFILDLL;
  4128. function    AVIFileOpenW(var ppfile: PAVIFILE; szFile: LPCWSTR; uMode: UINT; lpHandler: PCLSID): HResult; stdcall; external AVIFILDLL;
  4129.  
  4130. function    AVIFileOpen(var ppfile: PAVIFILE; szFile: LPCSTR; uMode: UINT; lpHandler: PCLSID): HResult; stdcall;  external AVIFILDLL name 'AVIFileOpenA';
  4131.  
  4132. function    AVIFileInfoW(pfile: PAVIFILE; pfi: PAVIFILEINFOW; lSize: DWORD): HResult; stdcall; external AVIFILDLL;
  4133. function    AVIFileInfoA(pfile: PAVIFILE; pfi: PAVIFILEINFOA; lSize: DWORD): HResult; stdcall; external AVIFILDLL;
  4134.  
  4135. function    AVIFileInfo(pfile: PAVIFILE; pfi: PAVIFILEINFOA; lSize: DWORD): HResult; stdcall;  external AVIFILDLL name 'AVIFileInfoA';
  4136.  
  4137. function    AVIFileGetStream(pfile: PAVIFILE; var ppavi: PAVISTREAM; fccType: DWORD; lParam: DWORD): HResult; stdcall; external AVIFILDLL;
  4138.  
  4139. function    AVIFileCreateStreamW(pfile: PAVIFILE; var ppavi: PAVISTREAM; psi: PAVISTREAMINFOW): HResult; stdcall; external AVIFILDLL;
  4140. function    AVIFileCreateStreamA(pfile: PAVIFILE; var ppavi: PAVISTREAM; psi: PAVISTREAMINFOA): HResult; stdcall; external AVIFILDLL;
  4141.  
  4142. function    AVIFileCreateStream(pfile: PAVIFILE; var ppavi: PAVISTREAM; psi: PAVISTREAMINFOA): HResult; stdcall; external AVIFILDLL name 'AVIFileCreateStreamA';
  4143.  
  4144. function    AVIFileWriteData(pfile: PAVIFILE; ckid: DWORD; lpData: PVOID; cbData: DWORD): HResult; stdcall; external AVIFILDLL;
  4145. function    AVIFileReadData(pfile: PAVIFILE; ckid: DWORD; lpData: PVOID; lpcbData: PDWORD): HResult; stdcall; external AVIFILDLL;
  4146. function    AVIFileEndRecord(pfile: PAVIFILE): HResult; stdcall; external AVIFILDLL;
  4147.  
  4148. function    AVIStreamAddRef(pavi: PAVISTREAM): UDWORD; stdcall; external AVIFILDLL;
  4149. function    AVIStreamRelease(pavi: PAVISTREAM): UDWORD; stdcall; external AVIFILDLL;
  4150.  
  4151. function    AVIStreamInfoW (pavi: PAVISTREAM; psi: PAVISTREAMINFOW; lSize: DWORD): HResult; stdcall; external AVIFILDLL;
  4152. function    AVIStreamInfoA (pavi: PAVISTREAM; psi: PAVISTREAMINFOA; lSize: DWORD): HResult; stdcall; external AVIFILDLL;
  4153.  
  4154. function    AVIStreamInfo(pavi: PAVISTREAM; psi: PAVISTREAMINFOA; lSize: DWORD): HResult; stdcall; external AVIFILDLL name 'AVIStreamInfoA';
  4155.  
  4156. function    AVIStreamFindSample(pavi: PAVISTREAM; lPos: DWORD; lFlags: DWORD): DWORD; stdcall; external AVIFILDLL;
  4157. function    AVIStreamReadFormat(pavi: PAVISTREAM; lPos: DWORD; lpFormat: PVOID; lpcbFormat: PDWORD): HResult; stdcall; external AVIFILDLL;
  4158. function    AVIStreamSetFormat(pavi: PAVISTREAM; lPos: DWORD; lpFormat: PVOID; cbFormat: DWORD): HResult; stdcall; external AVIFILDLL;
  4159. function    AVIStreamReadData(pavi: PAVISTREAM; fcc: DWORD; lp: PVOID; lpcb: PDWORD): HResult; stdcall; external AVIFILDLL;
  4160. function    AVIStreamWriteData(pavi: PAVISTREAM; fcc: DWORD; lp: PVOID; cb: DWORD): HResult; stdcall; external AVIFILDLL;
  4161.  
  4162. function    AVIStreamRead(
  4163.     pavi            : PAVISTREAM;
  4164.     lStart          : DWORD;
  4165.     lSamples        : DWORD;
  4166.     lpBuffer        : PVOID;
  4167.     cbBuffer        : DWORD;
  4168.     plBytes         : PDWORD;
  4169.     plSamples       : PDWORD
  4170.     ): HResult; stdcall; external AVIFILDLL;
  4171.  
  4172. function    AVIStreamWrite(
  4173.     pavi            : PAVISTREAM;
  4174.     lStart,
  4175.     lSamples        : DWORD;
  4176.     lpBuffer        : PVOID;
  4177.     cbBuffer        : DWORD;
  4178.     dwFlags         : DWORD;
  4179.     plSampWritten   : PDWORD;
  4180.     plBytesWritten  : PDWORD
  4181.     ): HResult; stdcall; external AVIFILDLL;
  4182.  
  4183. // Right now, these just use AVIStreamInfo() to get information, then
  4184. // return some of it.  Can they be more efficient?
  4185.  
  4186. function    AVIStreamStart(pavi: PAVISTREAM): DWORD; stdcall; external AVIFILDLL;
  4187. function    AVIStreamLength(pavi: PAVISTREAM): DWORD; stdcall; external AVIFILDLL;
  4188. function    AVIStreamTimeToSample(pavi: PAVISTREAM; lTime: DWORD): DWORD; stdcall; external AVIFILDLL;
  4189. function    AVIStreamSampleToTime(pavi: PAVISTREAM; lSample: DWORD): DWORD; stdcall; external AVIFILDLL;
  4190.  
  4191. function    AVIStreamBeginStreaming(pavi: PAVISTREAM; lStart, lEnd: DWORD; lRate: DWORD): HResult; stdcall; external AVIFILDLL;
  4192. function    AVIStreamEndStreaming(pavi: PAVISTREAM): HResult; stdcall; external AVIFILDLL;
  4193.  
  4194. {-- Helper functions for using IGetFrame -------------------------------------}
  4195.  
  4196. function    AVIStreamGetFrameOpen(pavi: PAVISTREAM; lpbiWanted: PBITMAPINFOHEADER): PGETFRAME; stdcall; external AVIFILDLL;
  4197. function    AVIStreamGetFrame(pg: PGETFRAME; lPos: DWORD): PVOID; stdcall; external AVIFILDLL;
  4198. function    AVIStreamGetFrameClose(pg: PGETFRAME): HResult; stdcall; external AVIFILDLL;
  4199.  
  4200. // !!! We need some way to place an advise on a stream....
  4201. // STDAPI AVIStreamHasChanged   (PAVISTREAM pavi);
  4202.  
  4203. {-- Shortcut function --------------------------------------------------------}
  4204.  
  4205. function    AVIStreamOpenFromFileA(var ppavi: PAVISTREAM; szFile: LPCSTR; fccType: DWORD;
  4206.                                    lParam: DWORD; mode: UINT; pclsidHandler: PCLSID): HResult; stdcall; external AVIFILDLL;
  4207. function    AVIStreamOpenFromFileW(var ppavi: PAVISTREAM; szFile: LPCWSTR; fccType: DWORD;
  4208.                                    lParam: DWORD; mode: UINT; pclsidHandler: PCLSID): HResult; stdcall; external AVIFILDLL;
  4209.  
  4210. function    AVIStreamOpenFromFile(var ppavi: PAVISTREAM; szFile: LPCSTR; fccType: DWORD;
  4211.                                   lParam: DWORD; mode: UINT; pclsidHandler: PCLSID): HResult; stdcall; external AVIFILDLL name 'AVIStreamOpenFromFileA';
  4212.  
  4213. {-- Use to create disembodied streams ----------------------------------------}
  4214.  
  4215. function    AVIStreamCreate(var ppavi: PAVISTREAM; lParam1, lParam2: DWORD;
  4216.                             pclsidHandler: PCLSID): HResult; stdcall; external AVIFILDLL;
  4217.  
  4218. // PHANDLER    AVIAPI AVIGetHandler         (PAVISTREAM pavi, PAVISTREAMHANDLER psh);
  4219. // PAVISTREAM  AVIAPI AVIGetStream          (PHANDLER p);
  4220.  
  4221. {-- Stuff to support backward compat. ----------------------------------------}
  4222.  
  4223. function    AVIStreamFindKeyFrame(pavi: PAVISTREAM; lPos: DWORD; lFlags: DWORD): DWORD; stdcall; external AVIFILDLL name 'AVIStreamFindSample';
  4224.  
  4225. // Non-portable: this is alias for method name
  4226. // FindKeyFrame FindSample
  4227.  
  4228. function    AVIStreamClose(pavi: PAVISTREAM): UDWORD; stdcall; external AVIFILDLL name 'AVIStreamRelease';
  4229. function    AVIFileClose(pfile: PAVIFILE): UDWORD; stdcall; external AVIFILDLL name 'AVIFileRelease';
  4230. procedure   AVIStreamInit; stdcall; external AVIFILDLL name 'AVIFileInit';
  4231. procedure   AVIStreamExit; stdcall; external AVIFILDLL name 'AVIFileExit';
  4232.  
  4233. {== AVISave routines and structures ==========================================}
  4234.  
  4235. function    AVIMakeCompressedStream(
  4236.     var ppsCompressed   : PAVISTREAM;
  4237.     ppsSource           : PAVISTREAM;
  4238.     lpOptions           : PAVICOMPRESSOPTIONS;
  4239.     pclsidHandler       : PCLSID
  4240.     ): HResult; stdcall; external AVIFILDLL;
  4241.  
  4242. // Non-portable: uses variable number of params
  4243. // EXTERN_C HRESULT CDECL AVISaveA (LPCSTR               szFile,
  4244. //      CLSID FAR *pclsidHandler,
  4245. //      AVISAVECALLBACK     lpfnCallback,
  4246. //      int                 nStreams,
  4247. //      PAVISTREAM      pfile,
  4248. //      LPAVICOMPRESSOPTIONS lpOptions,
  4249. //      ...);
  4250.  
  4251. function    AVISaveVA(
  4252.     szFile          : LPCSTR;
  4253.     pclsidHandler   : PCLSID;
  4254.     lpfnCallback    : TAVISAVECALLBACK;
  4255.     nStreams        : int;
  4256.     var ppavi       : PAVISTREAM;
  4257.     var plpOptions  : PAVICOMPRESSOPTIONS
  4258.     ): HResult; stdcall; external AVIFILDLL;
  4259.  
  4260. // Non-portable: uses variable number of params
  4261. // EXTERN_C HRESULT CDECL AVISaveW (LPCWSTR               szFile,
  4262. //      CLSID FAR *pclsidHandler,
  4263. //      AVISAVECALLBACK     lpfnCallback,
  4264. //      int                 nStreams,
  4265. //      PAVISTREAM      pfile,
  4266. //      LPAVICOMPRESSOPTIONS lpOptions,
  4267. //      ...);
  4268.  
  4269. function    AVISaveVW(
  4270.     szFile          : LPCWSTR;
  4271.     pclsidHandler   : PCLSID;
  4272.     lpfnCallback    : TAVISAVECALLBACK;
  4273.     nStreams        : int;
  4274.     var ppavi       : PAVISTREAM;
  4275.     var plpOptions  : PAVICOMPRESSOPTIONS
  4276.     ): HResult; stdcall; external AVIFILDLL;
  4277.  
  4278. // #define AVISave      AVISaveA
  4279.  
  4280. function    AVISaveV(
  4281.     szFile          : LPCSTR;
  4282.     pclsidHandler   : PCLSID;
  4283.     lpfnCallback    : TAVISAVECALLBACK;
  4284.     nStreams        : int;
  4285.     var ppavi       : PAVISTREAM;
  4286.     var plpOptions  : PAVICOMPRESSOPTIONS
  4287.     ): HResult; stdcall; external AVIFILDLL name 'AVISaveVA';
  4288.  
  4289. function    AVISaveOptions(
  4290.     hwnd            : HWND;
  4291.     uiFlags         : UINT;
  4292.     nStreams        : int;
  4293.     var ppavi       : PAVISTREAM;
  4294.     var plpOptions  : PAVICOMPRESSOPTIONS
  4295.     ): BOOL; stdcall; external AVIFILDLL;
  4296.  
  4297. function    AVISaveOptionsFree(nStreams: int; var plpOptions: PAVICOMPRESSOPTIONS): HResult; stdcall; external AVIFILDLL;
  4298.  
  4299. {-----------------------------------------------------------------------------}
  4300.  
  4301. function    AVIBuildFilterW(lpszFilter: LPWSTR; cbFilter: DWORD; fSaving: BOOL): HResult; stdcall; external AVIFILDLL;
  4302. function    AVIBuildFilterA(lpszFilter: LPSTR; cbFilter: DWORD; fSaving: BOOL): HResult; stdcall; external AVIFILDLL;
  4303.  
  4304. function    AVIBuildFilter(lpszFilter: LPSTR; cbFilter: DWORD; fSaving: BOOL): HResult; stdcall; external AVIFILDLL name 'AVIBuildFilterA';
  4305.  
  4306. function    AVIMakeFileFromStreams(var ppfile: PAVIFILE; nStreams: int; var papStreams: PAVISTREAM): HResult; stdcall; external AVIFILDLL;
  4307.  
  4308. function    AVIMakeStreamFromClipboard(cfFormat: UINT; hGlobal: THANDLE; var ppstream: PAVISTREAM): HResult; stdcall; external AVIFILDLL;
  4309.  
  4310. {-- Clipboard routines -------------------------------------------------------}
  4311.  
  4312. function    AVIPutFileOnClipboard(pf: PAVIFILE): HResult; stdcall; external AVIFILDLL;
  4313. function    AVIGetFromClipboard(var lppf: PAVIFILE): HResult; stdcall; external AVIFILDLL;
  4314. function    AVIClearClipboard: HResult; stdcall; external AVIFILDLL;
  4315.  
  4316. {-- Editing routines ---------------------------------------------------------}
  4317.  
  4318. function    CreateEditableStream(var ppsEditable: PAVISTREAM; psSource: PAVISTREAM): HResult; stdcall; external AVIFILDLL;
  4319.  
  4320. function    EditStreamCut(pavi: PAVISTREAM; plStart, plLength: PDWORD; var ppResult: PAVISTREAM): HResult; stdcall; external AVIFILDLL;
  4321. function    EditStreamCopy(pavi: PAVISTREAM; plStart, plLength: PDWORD; var ppResult: PAVISTREAM): HResult; stdcall; external AVIFILDLL;
  4322. function    EditStreamPaste(pavi: PAVISTREAM; plPos, plLength: PDWORD; pstream: PAVISTREAM; lStart, lEnd: DWORD): HResult; stdcall; external AVIFILDLL;
  4323. function    EditStreamClone(pavi: PAVISTREAM; var ppResult: PAVISTREAM): HResult; stdcall; external AVIFILDLL;
  4324.  
  4325. function    EditStreamSetNameA(pavi: PAVISTREAM; lpszName: LPCSTR): HResult; stdcall; external AVIFILDLL;
  4326. function    EditStreamSetNameW(pavi: PAVISTREAM; lpszName: LPCWSTR): HResult; stdcall; external AVIFILDLL;
  4327. function    EditStreamSetInfoW(pavi: PAVISTREAM; lpInfo: PAVISTREAMINFOW; cbInfo: DWORD): HResult; stdcall; external AVIFILDLL;
  4328. function    EditStreamSetInfoA(pavi: PAVISTREAM; lpInfo: PAVISTREAMINFOA; cbInfo: DWORD): HResult; stdcall; external AVIFILDLL;
  4329.  
  4330. function    EditStreamSetInfo(pavi: PAVISTREAM; lpInfo: PAVISTREAMINFOA; cbInfo: DWORD): HResult; stdcall; external AVIFILDLL name 'EditStreamSetInfoA';
  4331. function    EditStreamSetName(pavi: PAVISTREAM; lpszName: LPCSTR): HResult; stdcall; external AVIFILDLL name 'EditStreamSetNameA';
  4332.  
  4333. {-- MCIWnd -------------------------------------------------------------------}
  4334.  
  4335. function    MCIWndCreateA(hwndParent: HWND; hInstance: HINST; dwStyle: DWORd; szFile: LPCSTR): HWND; cdecl; external VFWDLL;
  4336. function    MCIWndCreateW(hwndParent: HWND; hInstance: HINST; dwStyle: DWORd; szFile: LPCWSTR): HWND; cdecl; external VFWDLL;
  4337.  
  4338. function    MCIWndCreate(hwndParent: HWND; hInstance: HINST; dwStyle: DWORd; szFile: LPCSTR): HWND; cdecl;  external VFWDLL name 'MCIWndCreateA';
  4339.  
  4340. function    MCIWndRegisterClass: BOOL; cdecl; external VFWDLL;
  4341.  
  4342. {== AVICAP - Window class for AVI capture ====================================}
  4343.  
  4344. {-- The only exported functions from AVICAP.DLL ------------------------------}
  4345.  
  4346. function    capCreateCaptureWindowA(
  4347.     lpszWindowName      : LPCSTR;
  4348.     dwStyle             : DWORD;
  4349.     x, y                : int;
  4350.     nWidth, nHeight     : int;
  4351.     hwndParent          : HWND;
  4352.     nID                 : int
  4353.     ): HWND; stdcall; external AVICAPDLL;
  4354.  
  4355. function    capGetDriverDescriptionA(
  4356.     wDriverIndex        : UINT;
  4357.     lpszName            : LPSTR;
  4358.     cbName              : int;
  4359.     lpszVer             : LPSTR;
  4360.     cbVer               : int
  4361.     ): BOOL; stdcall; external AVICAPDLL;
  4362.  
  4363. function    capCreateCaptureWindowW(
  4364.     lpszWindowName      : LPCWSTR;
  4365.     dwStyle             : DWORD;
  4366.     x, y                : int;
  4367.     nWidth, nHeight     : int;
  4368.     hwndParent          : HWND;
  4369.     nID                 : int
  4370.     ): HWND; stdcall; external AVICAPDLL;
  4371.  
  4372. function    capGetDriverDescriptionW(
  4373.     wDriverIndex        : UINT;
  4374.     lpszName            : LPWSTR;
  4375.     cbName              : int;
  4376.     lpszVer             : LPWSTR;
  4377.     cbVer               : int
  4378.     ): BOOL; stdcall; external AVICAPDLL;
  4379.  
  4380. function    capCreateCaptureWindow(
  4381.     lpszWindowName      : LPCSTR;
  4382.     dwStyle             : DWORD;
  4383.     x, y                : int;
  4384.     nWidth, nHeight     : int;
  4385.     hwndParent          : HWND;
  4386.     nID                 : int
  4387.     ): HWND; stdcall; external AVICAPDLL name 'capCreateCaptureWindowA';
  4388.  
  4389. function    capGetDriverDescription(
  4390.     wDriverIndex        : UINT;
  4391.     lpszName            : LPSTR;
  4392.     cbName              : int;
  4393.     lpszVer             : LPSTR;
  4394.     cbVer               : int
  4395.     ): BOOL; stdcall; external AVICAPDLL name 'capGetDriverDescriptionA';
  4396.  
  4397. {== FilePreview dialog =======================================================}
  4398.  
  4399. function GetOpenFileNamePreviewA(lpofn: POPENFILENAMEA): BOOL; stdcall; external VFWDLL;
  4400. function GetSaveFileNamePreviewA(lpofn: POPENFILENAMEA): BOOL; stdcall; external VFWDLL;
  4401.  
  4402. function GetOpenFileNamePreviewW(lpofn: POPENFILENAMEW): BOOL; stdcall; external VFWDLL;
  4403. function GetSaveFileNamePreviewW(lpofn: POPENFILENAMEW): BOOL; stdcall; external VFWDLL;
  4404.  
  4405. function GetOpenFileNamePreview(lpofn: POPENFILENAMEA): BOOL; stdcall; external VFWDLL name 'GetOpenFileNamePreviewA';
  4406. function GetSaveFileNamePreview(lpofn: POPENFILENAMEA): BOOL; stdcall; external VFWDLL name 'GetSaveFileNamePreviewA';
  4407.  
  4408. end.
  4409.